Artificial intelligent assistant

Expectation of a die roll summed I know this problem involves conditional probability, but I'm confused as to how to tackle it. Assume a die is rolled over and over, where the total is summed. If the die's roll is $\geq 3$ the game stops and the summed total is read out. What is the expectation of the total? What is the expected number of times the die was rolled?

The total number of rolls follows a geometric law of parameter $p=\dfrac{4}{6}=\dfrac{2}{3}$. Therefore the expected number of rolls is $1/p=\color{red}{1.5}$.

Therefore the expected total is $(1/p-1)\cdot 1.5 + 4.5=\color{red}{5.25}$, because $1.5$ is the mean of a roll between $1$ and $2$ (and you have an average of $1/p -1$ rolls between $1$ and $2$) and $4.5$ is the mean of the last roll (between $3$ and $6$).

By the way you can easily verify your results for this kind of problem with a simple python code:


import random as random

nb_trials = 10000
tot = 0

for i in range(nb_trials):
sum_value = 0
b = True
while b:
a = random.randint(1,6)
if a >=3:
b = False
sum_value += a
tot += sum_value

average = tot * 1.0 / nb_trials
print(average)


Try it online!

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 018a61710ba375d7cd812bcb55aa6278