Average value relating to probability

92 Views Asked by At

What is the average value relating to when a value different from a specific six-sided die is obtained?

2

There are 2 best solutions below

10
On BEST ANSWER

First, we need to know the probability that Sam rolls an odd total. The total will be odd if and only if an odd number of dice turn up odd numbers. If he rolls $n$ dice then the number of ways to choose an odd number of dice which come up odd is $$\sum_{k\text{ odd}}{n\choose k}=2^{n-1}$$ and since the probability of an odd or even number on each die is $\frac12,$ the probability of an odd total on any roll is $$2^{n-1}2^{-n}=\frac12.$$ Therefore, the probability that the game ends on roll number $k$ is $2^{-k}$.

Now we have to know the expected score if the game ends on roll k. Since $(1+3+5)/3=3$, the average roll on an odd die is $3,$ and the average roll on an even die is $(2+4+6)/3=4.$ If there are $j$ odd dice in the roll, there are $(k-j)$ even dice, so the expected value of a roll with $j$ odd dice is $3j+4(k-j).$ Since there are ${k\choose j}$ ways to choose the $j$ dice that will be odd, the expected total is $$2^{1-k}\sum_{j\text{ odd}}{n\choose j}(3j+4(k-j))$$ When $k$ is even, it's not hard to see that this works out to ${7k\over2}$ because each roll with $j$ odds and $k$ evens is balanced by a roll with $k-j$ odds and $j$ evens, and of course, if $j=k/2$ is odd then we have rolls with the same number of odds and evens.

To progress further, we need the average score for odd $k$. Clearly, when $k=1$ the average score is $3$. I claim that if $k+1$ is odd and $k>0$ then the expected score is ${7(k+1)\over2}.$ Observe that since $k$ is even we have already seen that the average odd score is with $k$ dice is ${7k\over2}.$ Furthermore, since the average roll with $k$ dice is also ${7k\over2}$ it must be the case that the average even roll is also ${7k\over2}$. Now with $k+1$ dice, the average score is $$ \begin{align} &2^{-k}\sum_{j\text{ odd}}{k+1\choose j}((3j+4(k+1-j))=\\ &2^{-k}\sum_{j\text{ odd}}\left({k\choose j}+{k\choose j-1}\right)(3j+4(k+1-j))=\\ &2^{-k}\sum_{j\text{ odd}}{k\choose j}(3j+4(k+1-j))+ 2^{-k}\sum_{j\text{ odd}}{k\choose j-1}(3j+4(k+1-j))\tag{1} \end{align}$$
The first of these sums is $$ 2^{-k}\sum_{j\text{ odd}}{k\choose j}(3j+4(k-j))+4\cdot2^{-k}\sum_{j\text{ odd}}{k\choose j}={7k\over 4}+2,$$ by what has gone before.

The second sum in $(1)$ is $$ 2^{-k}\sum_{j\text{ odd}}{k\choose j-1}(3(j-1)+4(k-(j-1)))+3\cdot2^{-k}\sum_{j\text{ odd}}{k\choose j-1}\tag{2}$$

The first sum in $(2)$ is one-half the average even score with $k$ dice, which is ${7k\over 4}$ as we have seen, and the second sum is $\frac32,$ so that the expected odd score with $k+1$ dice is $${7k\over4}+2+{7k\over4}+\frac32={7(k+1)\over2}$$ as claimed.

The expected score in the games is therefore $$\frac32+\frac72\sum_{k=2}^\infty k2^{-k}=\frac32-\frac74+\frac74\sum_{k=1}^\infty k\left(\frac12\right)^{k-1}=-\frac14+7={27\over4}.$$

To calculate $\sum_{k=1}^\infty k\left(\frac12\right)^{k-1}$ note that differentiate both sides of $${1\over 1-x}=\sum_{k=0}^\infty{x^k,}\ |x|<1$$ and set $x=\frac12,$ getting the value $4.$

EDIT

The mistake was in the very last line. I've corrected it now, and the answer agrees with my simulations. Here is the simulation script, if anyone wants to test it.

from random import choices

die = list(range(1,7))
trials = 10000

def game():
    dice =1
    while True:
        roll = choices(die, k=dice)
        s = sum(roll)
        if s%2==1: 
            return s
        dice += 1

score = 0
for _ in range(trials):
    score += game()

print(trials, score/trials)

Typical output is

10000 6.7242

ADDENDUM

I figured out a much easier way, using a generating function, to see the crux of the matter, namely that for $k>1$ the average odd roll with $k$ dice is ${7l\over 2}$ Let $$s(x)=(x+x^2+x^3+x^4+x^5+x^6)^k.$$ When this is expanded, the coefficient $x^s,$ call it $a_s$ is the number of different rolls with sum $s$ and the coefficient of $x^{s-1}$ in $f'(x)$ which is $sa_s$ is the total score on all rolls of sum $s$. Therefore, $f'(-1)$ is the difference between the sum of all possible odd rolls and all possible even rolls. Now, $$f'(x)=k(x+x^2+x^k+x^4+x^5+x^6)^{k-1}(1+2x+3x^2+4x^3+5x^4+6x^5)$$ and we see $$f'(-1)=0$$ (Note that this argument fails when $k=1.$)

Since we know that there are the same number of odd rolls and even rolls, and their sums are the same, their averages are the same, and they must be the average of all rolls which is plainly $3.5k.$ This makes most of the foregoing unnecessary, but I'll leave it as a cautionary tale.

4
On

A non recursive approach:

Let $S_k$ be the sum of $k$ dice rolled. Let $T_k$ be $1$ if $S_k$ is even, $0$ otherwise. Let $A$ be the total sum of this game.

We have $E[S_k]= k E[S_1]= k \, 3.5 \tag1$

Further, $E[T_k]= P(T_k=1) = 0.5\tag2$

And $S_k$ is independent of $S_j$ (and $T_j$) for $j\ne k$

Now, notice that $$A = S_1 + S_2 T_1 + S_3 T_1 T_2 +S_4 T_1 T_2 T_3+ \cdots\tag3$$

Can you go on from here?


Edited: This answer assumed that all the dices (from the first to the last roll) were to be summed. That is, if we get for example

   1st roll (1 dice): 2  (even, go on)
   2nd roll (2 dice): 3+3 = 6  (even, go on)
   3rd roll (3 dice): 3+1+1 = 5 (odd, stop)

then we return the total: $2 + 6 + 5 =13$

In that case, the procedure here is right (contrary to what the comments in the accepted answer says). And the expected value is obtained evaluating the sum $(3)$: $$A=14\tag4$$.

If, instead (as the accepted answer assumed) we should return only the last roll (in the example above, $5$), then the procedure can be still applied. In this case:

$$ A = S_1(1-T_1) + S_2 T_1(1-T_2)+S_3 T_1T_2(1-T_3)+\cdots \tag5$$

This is slightly more difficult to evaluate now, because $E[S_k T_k]$ must be computed. For this, we must note that the condition $T_k=1$ (sum of $k$ dices is even) does not influence the probability that the first (say) die is event, except for $k=1$. Then we obtain

$$ E[S_k T_k]= \begin{cases} 2 & (k=1)\\ k 7/4 & (k>1) \end{cases} \tag6 $$

Then

$$E[S_k T_1T_2 \dots T_{k-1}(1-T_k)]= \begin{cases} 7/2-2 = 3/2 & (k=1)\\ (1/2)^{k-1}k(7/2 -7/4)= (1/2)^{k}k \, 7/2 & (k>1) \end{cases} \tag7$$

and summing up:

$$ A =27/4 \tag8$$