# What function accurately describes the likelihood of getting X successes when rolling Y dice?

Pardon my statistical illiteracy and feel free to correct any silly/wrong terminology I use in this post.

There is an RPG system called Storytelling where the vast majority of dice rolls are

Roll x 10 sided dice
Re-roll any dice with a value z or higher
A success is a die with a value of t or higher
You need y successes


So one might call this equation P(x,z,y,t), where typically it would be P(x,y,10,8);

I believe that the default (P(x,y,10,8)) is exactly 1/3rd chance of success per die, but I'm not really sure where to go from there, and more importantly, it would be better to be able to express this accurately with numbers than having to resort to Monte-Carlo.

Oh, and for what it's worth (surely a good statistician will know this already) my guess is that to accurately handle the recursive re-rolling one must use a limit as re-roll approaches infinity.

-
the results that need to be re-rolled do not need to be considered as results. –  Ronald Apr 27 '12 at 16:30
Is $z$ really typically $10$? That means you re-roll any die which results in a $10$? Or is a ten-sided die labeled from $0$ to $9$? –  Thomas Andrews Apr 27 '12 at 19:22

I'm not clear about your use of letters x, y, z, and t - I don't think these are the most helpful letter choices and I think you may have mixed them up! - but I've tried to follow them.

In fact, this follows a Binomial distribution with n = x (number of rolls).

Crucially, the rolls that need to be re-rolled can be ignored because we only care about the final result. Anything higher than $z$ won't count, no matter how many times it happens, so the very final result is equally likely to be anything that's $(z-1)$ or lower.

You can imagine that some results will be a 'success and stop rolling', some will be a 'fail and stop rolling', and we actually don't care about the other cases - we only care about the dice roll where we stop!

So, I understand:

• a success is any result between $t$ and $z-1$ inclusive.
• a fail is any result between $1$ and $t-1$.

Then, the probability of a success (per dice) is given by $t-1/z-1$, according to your figures.

So, across $x$ different dice, we apply a Binomial distribution $X$ ~ $B(x, \frac{t-1}{z-1})$

and calculate $P(X\geq y)$

As an example, if you roll 3 dice:

 Roll 3d10 dice
Scores of 10 are rerolled
A 'success' is a score of 8 or 9
You need 1 'success' to win


This would follow a Binomial distribution with $n = 3$ and $p = \frac{2}{9}$, i.e. a $\frac{2}{9}$ chance of success per die.

And so, the probability of winning is equal to $P(X \geq 1)$ which is approx 53%

If, instead, you roll $n$ dice:

 Roll nd10 dice
Scores of 10 are rerolled
A 'success' is a score of 8 or 9
You need 1 'success' to win


Your chance of winning is, nearest percentage:

 n = 1: 22%
n = 2: 40%
n = 3: 53%
n = 4: 63%
n = 5: 72%

-
you can work out the probability of a success taking into account rerolls, but this will result in an infinite geometric sequence that will sum to the same (correct) result. –  Ronald Apr 27 '12 at 23:55

first:

So Roll X 10 sided dice. (s is sum of the X number of 10 sided dice)

$F_{10,x}(s) = \sum_{i=1}^{s-x+1} {F_{10,1}(i) F_{10,x-1}(s - i)}$

Now what is the prob that a single dice will have a value > z.

I would think that t < z. Then you just have to find the prob that P(dice(i) >t | dice(i) < z) = p (see below)

P(A|B) = P(union of A & B)/P(B)

Once you find that then use that your prob in a binomail dist. $f(y;x,p) = \Pr(Y = y) = {x\choose y}p^y(1-p)^{x-y}$

-
This shouldn't be an answer, it should be a comment. But I don't have the rep. sorry. –  yiyi Jan 26 '12 at 23:37
I think this falls under the rubrik of Bernoulli trials. Each die has a first acceptable value after any mandated re-rolling. This is a hack to simulate $z$-sided dice (assuming the faces are numbered starting at $0$), or $(z-1)$-sided dice (for faces numbers starting with $1$). Each die thus has success and failure probabilities, $p$ and $q=1-p$, respectively, given by $$q=\frac{t}{z}\,,\qquad p=\frac{z-t}{z}$$ or, if the face numbering starts at $1$, $$p=\frac{z-t}{z-1}\,,\qquad q=\frac{t-1}{z-1}\,.$$ So we can model the outcome of each individual die with a random variable $X$ which is $1$ (for success) with probability $p$, and $0$ (for failure) with probability $q$. The variable $X$ is sometimes called an indicator variable, the outcome of each die is called a Bernoulli process or trial, and as well for its distribution. When we have $n$ i.i.d. (independent, identically distributed) such events, we can model them with $n$ random variables $X_i$, for $1\le i\le n$. Now if we let $Y=\sum X_i$, notice that $Y$ counts the number of successes. It turns out that the sum $Y$, representing the total number of successes from $n$ i.i.d. Bernoulli trials, has a Binomial distribution, with parameters $n$ and $p$: $$\mathbb{P}\left[Y=k\right]=\href{http://en.wikipedia.org/wiki/Binomial_coefficient}{n\choose k}p^kq^{n-k}$$ Thus the probability of $y$ or more successes is $$\mathbb{P}\left[Y\ge y\right]=\sum_{k=y}^n{n\choose k}p^kq^{n-k}$$ which solves your problem. You may also be interested to know that the expected wait time for the first occurrence of a particular number of successes can be modeled as well, with the negative binomial distribution.