expected sum after rolling dice until getting 6 five times

59 Views Asked by At

We are rolling dice until we get 6 exactly five times. What is expected value of total sum? My approach: Lets denote $X_i$ - number rolled in $i$-th roll, and $S_n = \sum_{i=1}^{n}X_i$. So now i want to define stopping times for first 6, second 6, ... 5th 6. $$T_1(w)=\min(n : X_n(w) = 6)$$ $$T_k(w)=\min(n > T_{k-1}, X_n(w) = 6)$$ $$T := T_5$$ So T if i did not make any mistakes, we are looking for value of $\mathbb{E}[S_T]$. Using Wald identity, I get $$\mathbb{E}[S_T] = \mathbb{E}[T]\mathbb{E}[X_1] = 3.5* \mathbb{E}[T]$$ Now I am stuck, how am i supposed to calculate $\mathbb{E}[T]$?

2

There are 2 best solutions below

0
On

This answer is off-topic, I had misread the problem statement. It answers the expectation of the hitting time for the sequence $66666$.


Conditioning on the outcome of the first roll, $$E[T] = P(X_1\neq 6) E[T|X_1\neq 6] + P(X_1= 6) E[T|X_1= 6]= \frac 56 E[T|X_1\neq 6] + \frac 16 E[T|X_1= 6].$$

Given $X_1\neq 6$, the game restarts from scratch on the next roll, hence $E[T|X_1\neq 6] = E[1+T]$.

Conditioning on the outcome of the second toss, $$E[T|X_1= 6] = \frac 56 E[T|X_1\neq 6,X_2\neq 6 ] + \frac 16 E[T|X_1= 6,X_2= 6],$$ and for the same reason, $E[T|X_1\neq 6,X_2\neq 6 ] = E[2+T]$.

Iterate this reasoning and you will find an affine equation for $E[T]$. This approach is similar to that of defining a Markov chain with states $S$, $6$, $66,\ldots, 66666$ and setting up a system of equations for the hitting time of each state.


Another approach is to let $\tau_n$ the hitting time for the sequence $6\ldots 6$ with $n$ 6's. Note that we have the conditional distributions $$\tau_{n+1} | (\tau_n = k, S_{\tau_n+1}=6) \sim k+1$$ and $$\tau_{n+1} | (\tau_n = k, S_{\tau_n+1}\neq 6) \sim k+1+\tau_{n+1}.$$

Therefore $$E[\tau_{n+1}] = \begin{aligned}[t] &\sum_{k=1}^\infty P(\tau_n = k, S_{\tau_n+1}=6) E[\tau_{n+1}|\tau_n = k, S_{\tau_n+1}=6] \\&+ \sum_{k=1}^\infty P(\tau_n = k, S_{\tau_n+1}\neq 6) E[\tau_{n+1}|\tau_n = k, S_{\tau_n+1}\neq 6]. \end{aligned} $$ Thus $$ \begin{aligned} E[\tau_{n+1}] &= \sum_{k=1}^\infty P(\tau_n = k)P(S_{k+1}=6)E[k+1+\tau_{n+1}] + \sum_{k=1}^\infty P(\tau_n = k)P(S_{k+1}\neq 6)(k+1) \\ &= \frac 56 (E[\tau_n] + 1+ E[\tau_{n+1}) + \frac 16 (E[\tau_n] + 1), \end{aligned}$$ which yields the recurrence relation $$E[\tau_{n+1}] = 6E[\tau_{n}] + 6.$$

Since $\tau_1$ has Geometric distribution with parameter $\frac 16$, $E[\tau_1]=6$ and we can solve and find $$E[\tau_{n}] = \frac{6^{n+1}-6}5.$$

For $n=5$ the expected value is $9330$.

The validity of $E[\tau_{n}] = \frac{6^{n+1}-6}5$ can be ascertained by running simulations for small $n$, e.g., $n=3,4$.

import numpy as np

def find(arr, pat):
    L, l = len(arr), len(pat)
    for i in range(L-l+1):
        if arr[i:i+l] == pat:
            return i + l -1
    return -1

res = []
n = 4
pat = list(np.ones(n)) 
for _ in range(10000):
    sample = np.random.randint(1,7,10000)
    idx = find(list(sample), pat)
    if idx != -1:
        res.append(idx+1)
print(np.mean(res))
0
On

Let $R_n = \sum_{k=1}^n 1_{X_k = 6}$ and note that $R_n$ has Binomial distribution with parameters $(n,\frac 16)$.

Note also that $P(T>n) = P(R_n < 5) = \sum_{k=0}^4 \binom nk \frac 1{6^k} (\frac 56)^{n-k}$.

Then $$E[T] = \sum_{n=0}^\infty P(T>n) = \sum_{k=0}^4 \frac 1{5^k} \sum_{n=0}^\infty \binom nk (\frac 56)^{n}.$$

For each $k\in \{0,\ldots, 4\}$ you can evaluate the sum $\sum_{n=0}^\infty \binom nk (\frac 56)^{n}$, and you will find that $$E[T] = 30.$$

This is confirmed by the following simulation.

import numpy as np
res = []
for _ in range(1000):
    sample = np.random.randint(1,7,5000)
    idx = np.argwhere(sample==6)[4][0]
    res.append(idx+1)
print(np.mean(res))