Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

More statistics of dice rolls

Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
What is the average number of times you must roll a d6 to get two 6's in a row?

I believe it has something to do with the geometric distribution but haven't solved it yet.
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Expectation of rolls to achieve 1st success

E(X) = (.83)/(.17) = 5

Doesn't help.


Geometric distribution (trials until first success)

X = first success
X2 = second success

P(X=k) = (1-p)^[k-1]*p

P(X=1) = (.83)^[0]*.17 = .17
P(X=2) = (.83)^[1]*.17 = .14
P(X=3) = (.83)^[2]*.17 = .12
P(X=4) = (.83)^[3]*.17 = .10
P(X=5) = (.83)^[4]*.17 = .08
P(X=6) = (.83)^[5]*.17 = .07
P(X=7) = (.83)^[6]*.17 = .06
etc

P(X2=2) = P(X=1)*.17 = .03
P(X2=3) = P(X=2)*.17 = .02

etc?

Won't work either. Will only take into account the sequences of the first successes. You could get a first 6, then fail on the next roll and then two 6's in a row.
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Or... we know E(X) = 5

E(X2=X+1) also = 5

The earliest X2 can occur is E(X)+1

So, E(X)*E(X2=X+1)+1 = 5*5+1 = 26

???


A simulation of 100 series gives mean = 29.8, stdev = 25.61
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Code:
A = total trials for sequence
B = expected trials following a first 6

A = 1 + (1-p)*A + (p)*B
B = 1 + (1-p)*A

A = 1 + (1-p)*A + (p)*(1 + (1-p)*A)
A = 1 + A*(1-p) + (p) + A*(p) - A*(p)^2
A = 1 + A - A*(p) + (p) + A*(p) - A*(p)^2
A = 1 + A + (p) - A*(p)^2
0 = 1 + (p) - A*(p)^2
(p) = A*(p)^2 - 1
A = ((p) + 1) / (p)^2

A = (7/6) / (1/36) = 7*6 = 42


In other words...

E(X2) = (1/p) * (1/p + 1)
E(X3) = (1/p) * (1/p + 1) * (1/p + 2)..
 

Elwro

Arcane
Joined
Dec 29, 2002
Messages
11,749
Location
Krakow, Poland
Divinity: Original Sin Wasteland 2
Off the top of my head:

Prob that you'll get it right in 2 throws is 1/36

Prob that you'll succeed in 3 throws is 1/36 + [(prob that first die is not a 6)*(prob that both 2nd and 3rd are 6)] = 1/36 + 5/6*1/36 = 11/216

Prob that you'll succeed in 4 throws is 11/216 + [(prob that 2nd die is not a 6)*(prob that both 3rd and 4th are 6)] = 11/216 + 5/6*1/36

In general, prob that you'll succeed in n throws is 1/36 + [(n-2) * 5/6 * 1/36]

This gives probability 1/2 for n = 56. This n seems too high for me, so perhaps I screwed something up and shouldn't be using 5/6 or sth.

edit: That's because 112 / 5 = 22.4, I divided by 2 instead of by 5. The answer "23" looks more reasonable, thanks Marsal!.
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
You can't do it binomially (you need to calculate every permutation so it is an insane amount of work).

The problem is you are assuming that when you get your second 6 it will be right after the first, in fact it is most likely there will be several isolated 6's.
 
Joined
Sep 4, 2009
Messages
3,520
First off, slim the problem down to getting any 2 consecutive same numbers.

Chance of the second number being the same as the first = 1/6 = .16666
Chance of the third number being the same as the second = 5/6 * 1/6 = .13888
Chance of the fourth number being the same as the 3rd = 5/6 * 5/6 * 1/6 = .115740740
Chance of the fifth number being the same as the 4th = 5/6 * 5/6 * 5/6 * 1/6 = .09645

= .51 Chance of receiving 2 consecutive rolls with the same number within 5 rolls.

Now, we step back to our original problem of 2 consecutive 6 rolls, which means we have to roll an average of 5 * 6 = 30 dice rolls to get 2 sixes. It may actually be closer to 29 or so rolls though, since the original 5 rolls gave us a chance > 50%.
 

Elwro

Arcane
Joined
Dec 29, 2002
Messages
11,749
Location
Krakow, Poland
Divinity: Original Sin Wasteland 2
@ Hobbit, I don't assume this. And I don't do this binomially. You said "in a row" and that's what I tried to calculate. Probability of getting 2 6s in a row by throw number 4 is (probability you get it right in the first two throws) + (you DON't get it right in the first two throws, but get double 6s on throw 2 and 3) + (probability you DON't get it right in the first three throws, but get double 6s on throw 3 and 4).

Hm, seems I actually calculated something a bit different. Oh well. edit: yeah, a simple error in division.
 

Marsal

Arcane
Joined
Oct 2, 2006
Messages
1,304
Just a quick guess:

(35/36)^n = 0.5

n = 24.6

25 times?

EDIT: Actually, Elwro is right, IMO. He can't do basic algebra, but he's right :)

n = 22.4 not 56. That could be right, because I just looked at the pairs of dice and left out "edge" cases (ie. [2,6] and [6,3] should be counted, not just [6,6]).

So the answer is (IMO) 23 times.
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Right, so how many times do you flip a coin to get two heads in a row?

My answer is 6, what's yours?


Amended equation:

X1 = (1) / (p)^1
X2 = (p + 1) / (p)^2
X3 = (p^2 + p + 1) / (p)^3
etc



@ Hobbit, I don't assume this. And I don't do this binomially. You said "in a row" and that's what I tried to calculate. Probability of getting 2 6s in a row by throw number 4 is (probability you get it right in the first two throws) + (you DON't get it right in the first two throws, but get double 6s on throw 2 and 3) + (probability you DON't get it right in the first three throws, but get double 6s on throw 3 and 4).
I think it's your generalization which is messed up:
"In general, prob that you'll succeed in n throws is 1/36 + [(n-2) * 5/6 * 1/36] "
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Overweight Manatee said:
First off, slim the problem down to getting any 2 consecutive same numbers.

Chance of the second number being the same as the first = 1/6 = .16666
Chance of the third number being the same as the second = 5/6 * 1/6 = .13888
Chance of the fourth number being the same as the 3rd = 5/6 * 5/6 * 1/6 = .115740740
Chance of the fifth number being the same as the 4th = 5/6 * 5/6 * 5/6 * 1/6 = .09645

= .51 Chance of receiving 2 consecutive rolls with the same number within 5 rolls.

Now, we step back to our original problem of 2 consecutive 6 rolls, which means we have to roll an average of 5 * 6 = 30 dice rolls to get 2 sixes. It may actually be closer to 29 or so rolls though, since the original 5 rolls gave us a chance > 50%.
You were on the same track as me. The problem, is that you try to calculate expectation this binomial way which screws it up somehow, not sure how but it does.

What if the probability had been 90%? Just calculating the first line (probability that second dice is same as first) gives you more than 0.50. So is the expectation value for a sequence less than 2 rolls?

The real expectation roll to get a six is six rolls (1/p)... not five.
 

Elwro

Arcane
Joined
Dec 29, 2002
Messages
11,749
Location
Krakow, Poland
Divinity: Original Sin Wasteland 2
Hobbit Lord of Mordor said:
Right, so how many times do you flip a coin to get two heads in a row?
edit: the method is wrong, the numbers are right. Go to the next post.

Using the same method as before:

Prob that you'll get it right in 2 tosses is 1/4

Prob that you'll succeed in 3 tosses is 1/4 + [(prob that first coin is not a head)*(prob that both 2nd and 3rd are heads)] = 1/4 + 1/2 * 1/4= 3/8

Prob that you'll succeed in 4 tosses is 3/8 + [(prob that 2nd coin is not a head)*(prob that both 3rd and 4th are heads)] = 3/8 + 1/2 * 1/4 = 1/2

And you can check that this answer is right by explicit calculation: out of 16 possible 4-place sequences of heads and tails exactly 8 fulfill your criteria (1 - head, 0 -tail):

1111
1110
1101
1011
0111
1100
0110
0011

and no other sequence does. So the answer is "if you throw the coin 4 times, the chance for getting 2 heads in a row is 1/2". In general, as above, for n throws the chance is 1/4 + [(n-2)*1/2*1/4]...


.... which is clearly idiotical because if goes above 1 and it should never do this. It shouldn't grow by a fixed number for each increase of n. So, the answer to this particular problem is "4", but I still have to think about the method. Unfortunately, I don't have the time now.
 

Elwro

Arcane
Joined
Dec 29, 2002
Messages
11,749
Location
Krakow, Poland
Divinity: Original Sin Wasteland 2
Suppose you know the probability of success up to roll n. What is the probability of an n-element sequence which does NOT give you a success (i.e. does not contain two 1s in a row), but ends with a 1 (so that it is possible to achieve success in the next throw)? You have to multiply this number (call it "Z_n") by 1/2 to get the probability increase when going from n to n+1. Let's call the number of "bad" n-element sequences (= these which end with 0, and so make success in roll n+1 impossible) B_n.

For example, for n=2, Z_2 = 1/4: only the sequence 01 gives you a chance of success in roll 3. B_2 = 2 (sequences 10 and 00)

For n=3, Z_3 = 1/4: only the sequences 001 and 101 give you a chance of success in roll 4.

But how compute Z_n "in general"?

FACT: It is connected to the number B_{n-1}. In fact (for n>1), iZ_n = B_{n-1}/2^n

So, the chance of success in 2 throws is 1/4. We see that Z_2 = 1/4 and B_2 = 2. And so the increase of probability of success when going from 2 throws to 3 throws is Z_2 * 1/2 = 1/8, so the probability of success in 3 throws is 3/8.

With the above method, when moving from 3 throws to 4 throws we calculate Z_3 = 2/2^3 = 1/4, so B_3 = 3. And thus the success-probability gain when going from 3 throws to 4 throws is Z_3*1/2 = 1/8, so the probability of success in 4 throws is 1/2. But this is the end of "nice numbers". You can check that the success-probability gain when going from 4 throws to 5 throws is only 3/32 and will decrease from now on, which was to be expected so that the total probability of success does not go above 1 :)


This should be cleaned up and a generalization should be attempted; but it is fully enough to write a simple recursive procedure for calculating the number of throws needed to reach any given probability of success.
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
Elwro, haven't worked through your reasoning yet, here is my method for the d6 problem:

Code:
To check # rolls to get first "6" = E(X1) = 6

First roll is 6 = p(X1=1) = 1/6, n+1 and E(X1) = 0
First roll is not 6 = p(X1 =! 1) = 5/6, k+1 and E(X1) = 6

[If (EX1 = 1), n increases by 1
If E(X1 =! 1), n increases by 1 but E(X1) = 6]

Represent "lost" n by k.

Rolls are independent, failing the first roll has no effect on the second (aka, expectation remains the same).

=>

E(X1) = p(X1 =! 1) * (k + E(X1)) + p(X1 = 1) * (n)

E(X1) = 5/6 * (1 + 6) + 1/6 * (1) = 6

=> 

E(X1) = (1-p) * (1 + E(X1)) + (p) * (1)
E(X1) = 1 - (p) + E(X1) - (p)*E(X1) + (p) = 1 - (p)*E(X1) + E(X1)
0 = 1 - (p)*E(X1)
(p)*E(X1) = 1
E(X1) = 1 / (p)

=>

E(X1) = 1 / (1/6) = 6


Now, find second in sequence (X2)

First roll is 6 = p(X1=1) = 1/6
First roll is not 6 = p(X1 =! 1) = 5/6

If E(X1 =! 1), n increases by 1 but E(X1) = 6, k+1
If E(X1 = 1), n increases by 1, n+1

But this time, it does affect future rolls.

Now, E(X2) = 6 = E(X1)

Second roll following is a 6 = p(X2 = 2) = 1/6, n+1, E(X2) = 0
Second roll following is not a 6 = p(X2 =! 2) = 5/6, k+1, E(X1) = 6

E(X2) = p(X1 =! 1) * (k + E(X1)) + p(X1 = 1)^2 * (n) + p(X1 = 1)*p(X2 =! 2) * (n+k + E(X1))

E(X2) = (1-p) * (1 + E(X1)) + (p)^2 * (2) + (p)*(1-p) * (1 + 1 + E(X1))
E(X2) = 2*p^2 + 1 - p + E(X1) - p*E(X1) + p*2 - 2*p^2 + p*E(X1) - E(X1)*p^2
E(X2) = 1 + E(X1) + p - E(X1)*p^2 = 1 + p + E(X1)*(1 + p^2)

E(X2) = 5/6 * (1+6) + (1/6)^2 * (2) + 1/6*5/6 * (1+1 + 6) = 7
Here is a paper which seems to confirm it:
http://people.ccmr.cornell.edu/~ginsparg/INFO295/mh.pdf
 

Marsal

Arcane
Joined
Oct 2, 2006
Messages
1,304
I just saw this line and didn't look at the rest:

E(X2) = 5/6 * (1+6) + (1/6)^2 * (2) + 1/6*5/6 * (1+1 + 6) = 42

How about you learn basic algebra before tackling the "hard" stuff?
 
Joined
Aug 25, 2009
Messages
1,548
Location
Barad-dûr
So you have to multiply E(X1) by E(X2), big deal.

While you went off on an blatantly wrong track, but are convinced you are right... Yes it's such a trivial problem that a genius like you doesn't know how to solve it.


Code:
E(X2) = 1 + E(X2) + p - E(X2)*p^2 = 1 + p + E(X2)*(1 - p^2) 
E(X2) = 1 + p + E(X2) - E(X2)*p^2
E(X2)*p^2 = 1 + p
E(X2) = (1 + p) / (p^2) = (7/6) * (1/36) = 42
 

Marsal

Arcane
Joined
Oct 2, 2006
Messages
1,304
I went off on a blatantly wrong track, but am convinced I am right? And yet I admitted that Elwro had the right idea and I was wrong.

WTF is this:

E(X2) = (1 + p) / (p^2) = (7/6) * (1/36) = 42

The OP is solved, as far as I know. Elwro's logic seems sound and the result is about what you'd expect (a bit less than my result which failed to recognize some cases).
 

Elwro

Arcane
Joined
Dec 29, 2002
Messages
11,749
Location
Krakow, Poland
Divinity: Original Sin Wasteland 2
Hobbit Lord of Mordor said:
Elwro's solution is wrong.
My original reasoning was wrong; still, I think I'm on the right track with my last post.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom