Thread Rating:

Poll

16 votes (50%)
12 votes (37.5%)
5 votes (15.62%)
2 votes (6.25%)
10 votes (31.25%)
3 votes (9.37%)
6 votes (18.75%)
5 votes (15.62%)
10 votes (31.25%)
7 votes (21.87%)

32 members have voted

EdCollins
EdCollins
Joined: Oct 21, 2011
  • Threads: 18
  • Posts: 1293
February 15th, 2021 at 4:37:40 PM permalink
Quote: Ace2

Suppose you roll a fair die until some face has appeared six times. For instance, your rolls could be 42132253261242 (for six 2's).On average, how many rolls would it take?

19.74
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1387
  • Posts: 23278
February 15th, 2021 at 8:02:19 PM permalink
Quote: Ace2

Suppose you roll a fair die until some face has appeared six times. For instance, your rolls could be 42132253261242 (for six 2's).

On average, how many rolls would it take?




Integrate the following from 0 to infinity:

x*(exp(-x/6)*(1+x/6+x^2/72+x^3/1296+x^4/31104+x^5/933120))^5*exp(-x/6)*(x^5/933120)

The answer is 2597868106693535971 / 131621703842267136 = Approximation: 19.73738396371749
It's not whether you win or lose; it's whether or not you had a good bet.
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 24
  • Posts: 1038
February 16th, 2021 at 7:11:16 AM permalink
Quote: EdCollins

19.74

Please show your calculation
Itís all about making that GTA
ThatDonGuy
ThatDonGuy 
Joined: Jun 22, 2011
  • Threads: 105
  • Posts: 4920
February 16th, 2021 at 7:25:06 AM permalink
Quote: Ace2

Suppose you roll a fair die until some face has appeared six times. For instance, your rolls could be 42132253261242 (for six 2's).

On average, how many rolls would it take?



I get 2,597,868,106,693,535,971 / 131,621,703,842,267,136 = about 19.737384

This is a brute-force Markov chain problem which can be worked backwards.
Let (a,b,c,d,e,f) be the state with a 1s, b 2s, ..., f 6s
If E(a,b,c,d,e,f) is the expected number of rolls needed from state (a,b,c,d,e,f):
E(a,b,c,d,e,f) = 1 + 1/6 (E(a+1,b,c,d,e,f) + E(a,b+1,c,d,e,f) + E(a,b,c+1,d,e,f) + E(a,b,c,d+1,e,f) + E(a,b,c,d,e+1,f) + E(a,b,c,d,e,f+1))
Note E(a,b,c,d,e,f) = 0 if any of the variables = 6
If n = 7776 a + 1296 b + 216 c + 36 d + 6 e + f, and F(n) = E(a,b,c,d,e,f), then calculate F(46,655), then F(46,654), and so on down to F(0).

EdCollins
EdCollins
Joined: Oct 21, 2011
  • Threads: 18
  • Posts: 1293
February 16th, 2021 at 7:32:57 AM permalink
Quote: Ace2

Please show your calculation



Sorry. No "calculation." My answer was based upon a quick & dirty simulation I wrote via Excel.

Sub Dice_Rolls()
max_sims = 10000000: Randomize Timer:
For x = 1 To max_sims
For xx = 1 To 36
r_num1 = Int((6 - 1 + 1) * Rnd + 1)

If r_num1 = 1 Then one = one + 1
If r_num1 = 2 Then two = two + 1
If r_num1 = 3 Then three = three + 1
If r_num1 = 4 Then four = four + 1
If r_num1 = 5 Then five = five + 1
If r_num1 = 6 Then six = six + 1

If one = 6 Then
y = y + xx: Exit For
ElseIf two = 6 Then
y = y + xx: Exit For
ElseIf three = 6 Then
y = y + xx: Exit For
ElseIf four = 6 Then
y = y + xx: Exit For
ElseIf five = 6 Then
y = y + xx: Exit For
ElseIf six = 6 Then
y = y + xx: Exit For
End If
Next xx
one = 0: two = 0: three = 0: four = 0: five = 0: six = 0
Next x

MsgBox (y / max_sims)
End Sub
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 24
  • Posts: 1038
February 16th, 2021 at 8:44:59 AM permalink
Quote: Wizard


Integrate the following from 0 to infinity:

x*(exp(-x/6)*(1+x/6+x^2/72+x^3/1296+x^4/31104+x^5/933120))^5*exp(-x/6)*(x^5/933120)

The answer is 2597868106693535971 / 131621703842267136 = Approximation: 19.73738396371749

That is the correct answer! I knew the Wizard would get this one
Itís all about making that GTA
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 24
  • Posts: 1038
February 16th, 2021 at 8:47:23 AM permalink
Quote: EdCollins

Sorry. No "calculation." My answer was based upon a quick & dirty simulation I wrote via Excel.

A simulation is great for verifying a calculated solution, but I don't consider it a solution. Most problems are easy to simulate provided your computer has enough horsepower
Last edited by: Ace2 on Feb 16, 2021
Itís all about making that GTA
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1387
  • Posts: 23278
February 16th, 2021 at 10:01:53 AM permalink
Here is my solution in more detail (PDF).

Recommended integral calculator.
It's not whether you win or lose; it's whether or not you had a good bet.
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 24
  • Posts: 1038
February 16th, 2021 at 2:37:54 PM permalink
Quote: Wizard

Here is my solution in more detail (PDF).

Recommended integral calculator.

There is a more efficient approach to this problem. The expected waiting time to arrive at state S is the sum of the probabilities of not being in state S at all times (just like a geometric series). Using that logic, you get to the formula in one step and integrate over all time:

[{ (x/6)^5/5! + (x/6)^4/4! + (x/6)^3/3! + (x/6)^2/2 + (x/6) + 1} / e^(x/6) ]^6 dx
Itís all about making that GTA
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1387
  • Posts: 23278
February 17th, 2021 at 6:59:36 AM permalink
Quote: Ace2

Recommended integral calculator.

There is a more efficient approach to this problem. The expected waiting time to arrive at state S is the sum of the probabilities of not being in state S at all times (just like a geometric series). Using that logic, you get to the formula in one step and integrate over all time:

[{ (x/6)^5/5! + (x/6)^4/4! + (x/6)^3/3! + (x/6)^2/2 + (x/6) + 1} / e^(x/6) ]^6 dx



Hmmm. Thank you. I guess I should have thought of that.

Here is a new and improved solution.
Last edited by: Wizard on Feb 17, 2021
It's not whether you win or lose; it's whether or not you had a good bet.

  • Jump to: