# SR5: Chance of rolling 2 dice with a result of 5 or 6 and 4 dice with a result of one out of eight dice total

This question is regarding calculating probability for the SR5 role-playing game.

The setup: a number of d6, $n$, are rolled. Any dice that come up as a 5 or a 6 are considered ‘hits’, and they add to a running tally. More hits is better. If half or more of the $n$ dice come up as ones, this generates a glitch, which is generally undesirable. If there are no hits, and the glitch condition is met, this is considered a critical glitch, and this is Really Bad News.

I am trying to calculate probabilities for different scenarios using the above rules.

I already know how to calculate the probability of getting any number of hits for any number of dice. For example, to calculate the chance of getting exactly two hits out of six dice rolled, where $n$ is the number of dice total rolled (6), $r$ is the number of results I am interested in (2), and $p$ is the chance of getting a ‘hit’ ($1/3$), a binomial trial will give me the answer:

$$\frac{n!}{(n-r)!r!} p^r (1-p)^{n-r}$$

Which results in $80/243$. To calculate the chance of getting two or more hits, I use the same equation, starting with the probability of two hits, then three hits, and so on, up to the number of dice rolled. At this point, summing the results gives me the chance for rolling two or more hits. So far, so good. Using similar methods, I can calculate the odds of rolling half or more $1$’s.

The problem I have is I am unsure how to go about calculating a scenario where I get a number of hits -and- half or more of the dice come up ones. I can enumerate and tally, and have done so for up to three dice, but this becomes hard to do by hand past that. And by the rules of the game, it’s possible to roll upwards of 18 dice, at which point enumeration becomes quite a lot for even the computer to handle.

If anyone could give me guidance on how to answer the question posed in the title, I can probably take it from there to handle all scenarios I am interested in. As an end result, I’m hoping to be able to determine probability of rolling $r$ hits with a glitch, and chance of getting a critical glitch.

As an example output, through enumeration, for two dice, there’s a $7/36$ chance of a critical glitch, a $4/9$ chance of one hit ($1/9$ chance of one hit and a glitch, $3/9$ chance of a clean hit with no glitch), $1/9$ chance of two hits ($0$ chance of two hits and a glitch), and a $1/4$ chance of a null result (neither hits nor glitches).

Allow $t$ to be the total number of dice rolled, $H$ to be the probability of getting a 'hit' (a 5 or a 6, so $1/3$), $X$ to be the probability of rolling a 1 ($1/6$), and $N$ the probability of getting a result we aren't interested in (a 2,3, or 4, so $1/2$). Also allow $h$ to be the number of hits we are interested in, $x$ the number of 1's we are interested in, and $n$ to be $t-(x+h)$
With the above, I can calculate the probability of a specific arranged result. For the question as asked, it will look like $HHXXXXNN$, or $H^2X^4N^2$. The next step is to figure out how many states this arrangement can be formed into. This can be done with $\frac{n!}{h!x!n!}$. This leads us to a final answer of the probability of that arrangement multiplied by all the possible combinations of that arrangement, for a final answer of $$\frac{t!}{h!x!n!}H^2X^4N^2=\frac{35}{3888}\approx0.009$$
This can be used to get most of your standard results in Shadowrun 4th edition or 5th edition. For example, to calculate the chance of getting two hits and a glitch with eight dice, we can use the above result and sum it with the results for the arrangments $HHXXXXXN$ and $HHXXXXXX$, covering all the ways in which a glitch can result while still getting two hits.