On the probability and expectation of rolling 3 dice and get 4, 5, 6

diceexpected valueprobability

I am looking at the following questions on rolling 3 dice at the same time:

  1. Probability of getting 4, 5, 6 without particular order;
  2. If get a result different from 4, 5, 6, then roll again. What is the expectation of number of rolls;
  3. If get a result different from 4, 5, 6, then roll the dice which is not in the set {4, 5, 6} again, e.g. first roll gives 4, 5, 1, then roll the third dice only until get a 6. What is the expectation of number of rolls.

I am stuck with the third part and do not know how to approach to such question. For the first one, I get the probability $= \left( \frac{1}{6} \right)^3 \times 3\,! = \frac{1}{36}$. And the second question, I use the mean of a geometric distribution and get the expectation $=36$.

Best Answer

The model is a Markov chain with four states, $0,1,2,3$. The state $0$ is the initial state. The final state is $3$. (The state $k$ means roughly "$k$ matched positions".)

We associate the following constellations to the three states:

  • $0$ stays for something like $\{*,*,*\}$ where $*$ is some face not under $4,5,6$. This convention for the $*$ will be used below.
  • $1$ stays for something like $\{4,*,*\}$, for $\{5,*,*\}$ and for $\{6,*,*\}$ .
  • $2$ stays for something like $\{4,5,*\}$, for $\{4,6,*\}$ and for $\{5,6,*\}$ .
  • $3$ stays for the final state $\{4,5,6\}$ .

(Set delimiters are not really precise, because the roll $1,2,1$ may lead to interpretations when written as $\{1,2,1\}$, but something like $4,*,*$ between set delimiters means a four in some place, then further two no longer useful values (including a possible further occurence of the four, which became useless).)

The passage from one state to the other is given by the scheme:

     --- 1/36-----------------
    /                         \
   --- 5/12 ----------         \
  /            _1/18__\_________\
 /            /        \         \
[0] -----> [1] -----> [2] -----> [3]
/ \  2/3   / \  1/2   / \  1/6   / \
\_/        \_/        \_/        \_/
1/8        4/9        5/6         1

Let $N_k$ the expected number of rolls needed to pass from the state $k$ to the final state $3$. Then $N_3=0$. Else, $N_k>0$, so we make one step, and get a new state $n$ with the specified passing probabilities, from there we expect $N_n$ steps.

The system is: $$ \left\{ \begin{aligned} N_0 &= 1 + \frac 18N_0+\frac {37}{72}N_1+\frac 13N_2+\frac 1{36}N_3\ ,\\ N_1 &= 1 + \frac 49N_1+\frac 12N_2+\frac 1{18}N_3\ ,\\ N_2 &= 1 + \frac 56N_2+\frac 16N_3\ ,\\ N_3 &=0\ . \end{aligned} \right. $$ We solve this system, the solution is:

  • $N_3=0$, clear,

  • $N_2=6$, of course,

  • $N_1=36/5=7.2$,

  • $\color{red}{N_0=268/35\approx 7.6571428571428\dots}$ , which is the number asked in the OP.


Some words on the computed passage probabilities $p_{kn}$ from the state $k$ to the state $n$.

  • $p_{00}$ is $\frac 36\cdot\frac 36\cdot\frac 36=\left(\frac 12\right)^3=\frac 18$.
  • $p_{01}$ is computed as follows. We have three "empty places" to fill in with dice results, we are doing this in a strict order, one by one, and can have the possibilities (hit, - , -) and (-, hit, -) and (-, -, hit). It is important to have the order, because (hit, -, -) would mean a hit on the first place, say it is a $4$, then on the second place a $4$ is no longer a hit. So $(4,4,1)$ is in the first set of possibilities. But not in the second one. Then for the three cases we have in sum $$ p_{01} = \frac 36\cdot\frac 46\cdot\frac 46+ \frac 36\cdot\frac 36\cdot\frac 46+ \frac 36\cdot\frac 36\cdot\frac 36\\ =\frac 3{6^3}(16+12+9) =\frac{37}{72}\ . $$
  • $p_{03}$ is $\frac 36\cdot\frac 26\cdot\frac 16=\frac 1{36}$.
  • $p_{02}$ is the difference... Or we can build the cases (hit, hit, -) and (hit, -, hit) and (-, hit, hit) with the same order condition, then count $$ p_{02} = \frac 36\cdot\frac 26\cdot\frac 56+ \frac 36\cdot\frac 46\cdot\frac 26+ \frac 36\cdot\frac 36\cdot\frac 26 \\= \frac 1{6^3}\cdot 3\cdot 2(5+4+3) =\frac {12}{36}=\frac 13\ . $$
  • $p_{11}$ is $\frac 46\cdot\frac 46=\left(\frac 23\right)^2=\frac 49$.
  • $p_{13}$ is $\frac 26\cdot\frac 16=\frac 1{18}$.
  • $p_{12}$ is the difference... or we can count separately the probabilities when the hit is on the first position, then on the second position, i.e. (hit, -) and (-, hit) getting $\frac 26\cdot\frac 56+\frac 46\cdot\frac 26=\frac2{36}(5+4)=\frac 12$.
  • $p_{22}$ is $\frac 56$, and the rest is $p_{23}$.

Let us simulate. This is the best test. (Sage code is following.)

import random
N = 10^6
STEPS = 0

R = [1, 2, 3, 4, 5, 6]

roll = {1: cartesian_product([R]),
        2: cartesian_product([R, R]),
        3: cartesian_product([R, R, R]), }

for _ in range(N):
    still_needed = {4,5,6}
    while still_needed:
        STEPS += 1
        k = 3 - len(still_needed)
        dice = random.choice( roll[3-k] )
        still_needed = still_needed.difference(dice)
        
print("Statistic average: %s" % (STEPS/N).n())

And this time i've got:

Statistic average: 7.65439500000000

which is not far away from the obtained value $268/35\approx 7.65714285714286\dots$

OK, two more time the same simulation, since i do not like the deviation:

Statistic average: 7.65246400000000
Statistic average: 7.64682600000000

(One may compute the variance using similar methods.)

Related Question