# Probability formula for number of rolls to get a particular result

**URL:** <https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042>\
**Category:** Factual Questions\
**Created:** [August 21, 2022, 5:59pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042 "2022-08-21T17:59:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ponderoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponderoid/32/19221_2.png) [@Ponderoid](https://boards.straightdope.com/u/Ponderoid)\
**Post date:** [August 21, 2022, 5:59pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/1 "2022-08-21T17:59:52Z")

</div>

If I have an N-sided die and I want to hit a particular number in that range 1-N, what is the formula for the average or expected number of times I’ll have to roll it before I get the one I want?

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [August 21, 2022, 6:07pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/2 "2022-08-21T18:07:58Z")

</div>

Short answer: N.

The number of rolls it takes before you (first) get a particular value follows a geometric distribution.

The mean, or expected value, of such a distribution, is 1/p. In this case, assuming all sides of the die are equally likely to come up, p = 1/N, so the mean is 1/(1/N) = N.

(I assume that if I am mistaken about any of this, other Dopers will be along to correct me.)

---

<div class="post-metadata">

**Author:** ![Ponderoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponderoid/32/19221_2.png) [@Ponderoid](https://boards.straightdope.com/u/Ponderoid)\
**Post date:** [August 21, 2022, 6:21pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/4 "2022-08-21T18:21:20Z")

</div>

Thanks, both of you. Very helpful.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [August 21, 2022, 8:19pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/5 "2022-08-21T20:19:25Z")

</div>

Of course, even though the mean is n, in practice, it can take significantly more or less than that. In particular, if you’re rolling until you’ve hit all of the numbers, that’ll usually take a lot longer than n. Whatever the last one is, it’ll seem like the die is biased against that number, but really, something has to be the last one.

IIRC, this is called the “coupon collector problem”.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [August 21, 2022, 10:44pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/6 "2022-08-21T22:44:28Z")

</div>

The coupon collector problem is when you add a bunch of them up. For a single number, people usually talk about a geometric distribution. The point is that it has a long tail:  
[![](https://i.stack.imgur.com/iItFE.jpg) ](https://i.stack.imgur.com/iItFE.jpg)

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 5:42am UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/7 "2022-08-22T05:42:48Z")

</div>

You got the intuitive answers. But here’s the more mathematical breakdown (Doing it the brute-force way. I’m sure there’s something more elegant.).

The expected value of the number of rolls to hit a particular number on a 6-sided die is a sum that looks like this:  
 E = 1 \frac{1}{6} + 2 \frac{1}{6}\frac{5}{6} + 3 \frac{1}{6}\frac{5}{6}^2 + ...

I.e., 1 times the odds of hitting it on the first roll; 2 times the odds of hitting it on the second, but not the first; and so on.

Generalized and put in summation form:  
 E = \sum\_{k=1}^{\infty} k \frac{1}{N} (\frac{N-1}{N})^{k-1}

Rearrange things a bit:  
 N E = \sum\_{k=1}^{\infty} k (\frac{N-1}{N})^{k-1}

N E = 1 (\frac{N-1}{N})^0 + \sum\_{k=2}^{\infty} k (\frac{N-1}{N})^{k-1}

N E = 1 + \sum\_{k=2}^{\infty} k (\frac{N-1}{N})^{k-1}

Renumber k:  
 N E = 1 + \sum\_{k=1}^{\infty} (k + 1) (\frac{N-1}{N})^{k}

N E = 1 + \sum\_{k=1}^{\infty} k (\frac{N-1}{N})^{k} + \sum\_{k=1}^{\infty} 1 (\frac{N-1}{N})^{k}

N E = 1 + \frac{N-1}{N} \sum\_{k=1}^{\infty} k (\frac{N-1}{N})^{k-1} + \sum\_{k=1}^{\infty} 1 (\frac{N-1}{N})^{k}

Key step here! Recognize that the term in the middle is equal to NE, from way back:  
 N E = 1 + \frac{N-1}{N} NE + \sum\_{k=1}^{\infty} 1 (\frac{N-1}{N})^{k}

N E = 1 + E (N-1) + \sum\_{k=1}^{\infty} (\frac{N-1}{N})^{k}

Next key step! The other sum is an ordinary geometric sum, equal to \frac{M}{1-M}  
 N E = 1 + E (N-1) + \frac{\frac{N-1}{N}}{1- \frac{N-1}{N}}

N E = 1 + E (N-1) + (N - 1)

N E = 1 + EN - E + N - 1

E = N

QED

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [August 22, 2022, 9:59am UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/8 "2022-08-22T09:59:37Z")

</div>

If you are going to recognize geometric functions, you may as well note that

\sum\_{k\ge0}x^k = \frac{1}{1-x}

so

\frac{d}{dx}\sum\_{k\ge0}x^k = \sum\_{k\ge0}kx^{k-1} = \frac{1}{(1-x)^2}

and

\sum\_{k\ge0}kx^k=\frac{x}{(1-x)^2}.

More generally you can expand (1-x)^{-a}, and there is a lot you can do to manipulate sums using hypergeometric functions.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 10:14am UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/9 "2022-08-22T10:14:44Z")

</div>

Nice one. I was wondering how to get that k out in front and didn’t think about using the derivative. That definitely would have saved some steps. Well, at least the proof I gave didn’t require calculus…

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [August 22, 2022, 10:31am UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/10 "2022-08-22T10:31:32Z")

</div>

It is a mistake to disregard any kind of calculus or complex analysis when dealing with probability, but in this case what we are dealing with is the [binomial series](https://en.wikipedia.org/wiki/Binomial_series), which may be widely familiar.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 8:04pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/12 "2022-08-22T20:04:02Z")

</div>

> [@DPRK](#):
>
> It is a mistake to disregard any kind of calculus or complex analysis when dealing with probability

Most certainly. Nothing against calculus of course, but I think it’s still useful to have a purely algebraic answer in case the OP’s abilities stop there. Speaking personally, while I find calculus-based steps like your example are easy to understand, actually using them as a tool when constructing proofs is much more difficult. It takes much more of a proof mindset than I have the practice for.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [August 22, 2022, 8:22pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/13 "2022-08-22T20:22:01Z")

</div>

Apologies, especially since I accidentally posted the wrong graph!!! Let me make my own plots;

Let p = 1/6.  
[![](http://i.ompldr.pw/anjnar.png) ](http://i.ompldr.pw/anjnar.png)  
This is the geometric distribution.

The _y_-axis is the probability density. The blue line tends to zero exponentially, though there is still a substantial tail past the expectation which is in this case 6. Also NB only positive integer values of _x_ are relevant here even though I drew a smooth line through all the points.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [August 22, 2022, 10:13pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/15 "2022-08-22T22:13:09Z")

</div>

It’s much, much easier to prove. Imagine that you make many, many rolls of the dice (like, say, 6n, in the limit as n → infinity). How many 6s will you get? n, of course, by the definition of probability. And if you have n 6s in 6n rolls, then there must, on average, be 6 rolls in between.

---

<div class="post-metadata">

**Author:** ![Buck\_Godot](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/buck_godot/32/6573_2.png) [@Buck\_Godot](https://boards.straightdope.com/u/Buck_Godot)\
**Post date:** [August 22, 2022, 10:23pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/16 "2022-08-22T22:23:54Z")

</div>

Typical dope response to a simple probability question.

Correct one letter answer is given in post 2, followed by 15 posts deconstructing the problem in every way possible. Alas leaving very little left for me to add my own two cents. ☹

God I love this place, at long last I’ve found my tribe. 😄

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 10:31pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/17 "2022-08-22T22:31:21Z")

</div>

> [@Chronos](#):
>
> And if you have n 6s in 6n rolls, then there must, on average, be 6 rolls in between.

That is the intuitive answer that I referenced.

And yet there is something mysterious about it to me. If you consider a long random sequence, the gaps clearly must average 6 between the same number. But if I “join” that sequence at a random place, shouldn’t it average about _halfway_ through any given gap? Why is the number of rolls until the number is hit not _half_ the average gap length?

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [August 22, 2022, 10:49pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/18 "2022-08-22T22:49:49Z")

</div>

If you have a sequence that is _exactly_ one six every sixth roll, then if you pick a random starting point, there’s an equal chance that there’s 1, 2, 3, 4, or 5 rolls to the next 6 - and the average of that is 3. But we’re looking at a sequence that _averages_ one six every sixth roll, so if you start at random in that sequence, there’s a chance that’s there’s 1, 2, 3, 4, 5, 6, 7, 8, 9, and so on, rolls before the next six - and the average of that turns out to be 6 (from the arguments above).

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 10:56pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/19 "2022-08-22T22:56:09Z")

</div>

I agree with that, and it’s more or less what I came up with. But this is rather hand-wavey:

> there’s a chance that’s there’s 1, 2, 3, 4, 5, 6, 7, 8, 9, and so on, rolls before the next six - and the average of that turns out to be 6 (from the arguments above).

The answer is straightforward mathematically. But it’s not _immediately_ obvious why the weighted average of all possible roll gaps from an arbitrary starting point should equal the average gap length.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [August 22, 2022, 11:12pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/20 "2022-08-22T23:12:52Z")

</div>

Fair enough. It is weird that if you pick an arbitrary startpoint in the middle of a long sequence of rolls, the average number of rolls to the next six is the same as the average number of rolls since the last six.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 22, 2022, 11:23pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/21 "2022-08-22T23:23:40Z")

</div>

Yeah. In my proof above, it is surprising that everything cancels so nicely.

Expanding on this:

> [@Andy\_L](#):
>
> If you have a sequence that is _exactly_ one six every sixth roll

Let’s say you have a special die, that always rolls sequentially through a random permutation of numbers. So for instance, it might roll through 3-2-5-4-6-1-3-2-5-4-6-1-etc. Clearly the average gap is 6 and the long-term frequency of each number is 1/6. How do we calculate E in this case? Well, it’s just:  
 1\frac{1}{6} + 2\frac{1}{5}\frac{5}{6} + 3\frac{1}{4}\frac{4}{5}\frac{5}{6} + 4\frac{1}{3}\frac{3}{4}\frac{4}{5}\frac{5}{6} + 5\frac{1}{2}\frac{2}{3}\frac{3}{4}\frac{4}{5}\frac{5}{6} + 6\frac{1}{1}\frac{1}{2}\frac{2}{3}\frac{3}{4}\frac{4}{5}\frac{5}{6}

Clearly, all that cancels to:  
 \frac{1}{6} + \frac{2}{6} + \frac{3}{6} + \frac{4}{6} + \frac{5}{6} + \frac{6}{6}

Giving the average of 3.5 that we expect.

What sets that apart from my proof in #7 is that the rolls are not independent, making the tail much shorter (finite, even). The sum is totally different.

So any intuitive proof that _doesn’t_ depend on the independence of die rolls can’t be complete. It’s not enough to just look at gap length and frequency.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [August 22, 2022, 11:26pm UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/22 "2022-08-22T23:26:38Z")

</div>

> [@Dr.Strangelove](#):
>
> So any intuitive proof that _doesn’t_ depend on the independence of die rolls can’t be complete

Nice. Recognizing which _givens_ are keystones means that you really understand the problem

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [August 23, 2022, 5:03am UTC](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042/23 "2022-08-23T05:03:15Z")

</div>

The simpler derivation of the independent (ordinary die) case, using **DPRK** ’s method. The original sum:  
 E = \sum\_{k=1}^{\infty} k \frac{1}{N} (\frac{N-1}{N})^{k-1}

NE = \sum\_{k=1}^{\infty} k (\frac{N-1}{N})^{k-1}

NE = \sum\_{k=0}^{\infty} k (\frac{N-1}{N})^{k-1}

Noting this equivalency:  
 \frac{d}{dx} \sum\_{k=0}^{\infty} x^k = \sum\_{k=0}^{\infty} kx^{k-1} = \frac{d}{dx} \frac{1}{1 - x} = \frac{1}{(1 - x)^2}

Performing the substitution, assuming x=\frac{N-1}{N}  
 NE = \frac{1}{(1 - \frac{N-1}{N})^2} = \frac{1}{(\frac{1}{N})^2} = N^2

E = N   
 \blacksquare

[Next page](https://boards.straightdope.com/t/probability-formula-for-number-of-rolls-to-get-a-particular-result/970042.md?page=2)
