# Thread: X Attempts at a certain die roll with a retry

1. ## X Attempts at a certain die roll with a retry

A friend of mine have been discussing a scenario where you get a certain amount of tries at rolling higher than a particular number on a die (for example, rolling a 3 up on a 6 sided die). Weve been trying to figure out the average amount of successes if you can retry one failed die roll.

We got this far:
3 up on a 6 sided die has a 2/3 chance.
average number of successes from x rolls is x*2/3
chance to succeed x times in a row is 2/3^x
chance to fail at least once on x tries (and thus be able to use the reroll) is 1-(2/3^x)
average number of successes begotten from the reroll is thus (1-(2/3^x))*2/3
which leaves us with our end conclusion that the average number of successes is:
(x*2/3)+((1-(2/3^x))*2/3) or simplified (x+1-(2/3^x))*2/3

Weve also concocted a quick-and-dirty computer program that runs the situation a million times to get a decent average result.

Now the problem is that out math and our program produce different results(3.06... vs 3.20... for x=4) and were not sure wether our math is wrong (math class has been a while for both of us) or if it's the program.

So I figured I'd ask some fancible mathy folk like yourselves to give an opinion on wether our math is on to something or way the heck off. (And in the case of the latter, what the actual propper formula would be)

Also, as a bonus question. What if there was more than one reroll?

2. For the math approach to the problem, let p be the probability of success for a roll (so p=2/3 here), and let q = 1–p. For n rolls (without any reroll) the expected number of successes is given by the sum

$\displaystyle \sum_{k=0}^n{n\choose k}p^{n-k}q^k(n-k),$

and this sum is equal to $np$.

Now suppose that one reroll is allowed. There is a probability $p^n$ that every roll will be a success, in which case no reroll is needed. But in every other case, there is at least one failure, and the reroll gives an expected success of p (instead of the zero that it would be if no reroll were allowed). So the formula for the expected number of successes becomes

$\displaystyle p^nn + \sum_{k=1}^n{n\choose k}p^{n-k}q^k(n-k + p).$

That can be simplified to

$\displaystyle \sum_{k=0}^n{n\choose k}p^{n-k}q^k(n-k) + \sum_{k=1}^n{n\choose k}p^{n+1-k}q^k = np + p(1-p^n) = p(n+1-p^n).$

If you take p = 2/3 and n=4, this formula agrees with the formula (x+1-(2/3^x))*2/3 above, and gives the expected number of successes as $\frac{778}{243}\approx 3.2016461.$

If you allow a second reroll, then as well as the case where no reroll is needed, there is also a case where one reroll is needed, and for all other cases you need both rerolls. So the formula for the expected number of successes becomes

$\displaystyle p^nn + {n\choose 1}p^{n-1}q(n-1+p) + \sum_{k=2}^n{n\choose k}p^{n-k}q^k(n-k + 2p).$

I'll leave you to simplify that.