[Solved] Geometric Distribution – Expected number of rolls of a die before a value occurs [closed]


I think what you’re looking for is a sum of an infinite series. We basically need to model every scenario – that is we need to sum the expected value of getting a 5 on the 1st, 2nd, 3rd, 4th, etc rolls. To do this we can use a simple sum (not infinite, but a large number to basically get “close” to infinite behavior). The code to do that in R is:

x<-100
rolls<-0
for (i in 1:x){
  rolls<-rolls + (5/6)^(i-1)*(1/6)*i
}

Putting this code into plain english we have:

  • Sum the first 100 rolls
  • For each roll, n, the probability of a 5 on that roll = (probability of not getting a 5 on all rolls leading up to roll n) * (probability of 5 on roll n)
  • The probability of not getting a 5 on all rolls leading up to roll n = (prob of not 5^(n-1)) = (5/6^(n-1))
  • Probability of a 5 on any given roll is 1/6

Finally now that we have the probability of a 5 on any given roll, n (which is just (5/6^n-1 * 1/6), then we can multiply this probability by the roll number to get the expected value of each roll. This gives us the equation seen in the code.

Looking at the result we see that is converges to 6:

rolls
[1] 5.999999

You can probably solve this without doing any programming, but its been a while since I did that type of math.

solved Geometric Distribution – Expected number of rolls of a die before a value occurs [closed]