4
$\begingroup$

You roll a fair die until the cumulative sum rolled so far is a multiple of 3. You get $1 for each roll. What is the expected amount you will get?

I started by finding the probability of the game ending with "i" rolls, P(i). If I have this, I can then find the expectation. P(1), the probability of the game ending in 1 turn is 1/3 as either 3 or 6 can end the game. I continued doing this for P(2), P(3), etc., by writing down the sample space. It was too cumbersome and didn't know if it would end. Is there a more structured way to solve this problem?

$\endgroup$
6
  • $\begingroup$ This is not a homework question. I was asked this question in an interview but I am not sure how to solve this. $\endgroup$
    – gaganso
    Commented Oct 2, 2023 at 4:49
  • $\begingroup$ Please add the self-study tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. Note that this policy and the self-study tag also apply in your situation. $\endgroup$ Commented Oct 2, 2023 at 5:46
  • $\begingroup$ Also, please clarify what you mean by "a dice". The singular of "dice" is "die", so are you rolling one die or multiple ones? If a single die, what do you mean by "the sum of the values that show up"? Do you mean the cumulative sum rolled so far? $\endgroup$ Commented Oct 2, 2023 at 5:48
  • $\begingroup$ @StephanKolassa, thank you for the suggestions. I have added the tag, changed the dice to die and described my approach. $\endgroup$
    – gaganso
    Commented Oct 2, 2023 at 17:24
  • 2
    $\begingroup$ At each step, the chance that the cumulative sum will be a multiple of 3 is always 1/3, no matter what the cumulative sum currently is. Thus, you are really rolling a three-sided die until a specified side appears. $\endgroup$
    – whuber
    Commented Oct 2, 2023 at 17:59

2 Answers 2

4
$\begingroup$

You can make this very complicated, but the main trick is probably to recognize that

"independent from the current cumulative value there is a 1/3-th probability that a roll ends the game"

Then this game has a distribution of number of dice rolls that is geometric distributed with parameter $p=1/3$ and this has an expectation value of $1/p = 3$.

$\endgroup$
2
$\begingroup$

upd Sorry for making the solution so complicated, whereas the result is definitely true.


We use DiscreteMarkovProcess to model the process:

enter image description here

Mathematica code:

Clear["Global`*"];
transferMatrix = ConstantArray[1/3, {3, 3}];
transferMatrix[[3]] = {0, 0, 1};
(transferMatrix) // MatrixForm
\[CurlyPhi] = DiscreteMarkovProcess[{1, 0, 0}, transferMatrix];

VisualizeOneMarkovProcess[\[CurlyPhi]_] := 
 Graph[\[CurlyPhi], VertexLabels -> Placed["Name", Center], 
  VertexSize -> Large, 
  EdgeLabels -> 
   With[{sm = 
      MarkovProcessProperties[\[CurlyPhi], "TransitionMatrix"], 
     statesNumber = 
      Length@MarkovProcessProperties[\[CurlyPhi], 
        "InitialProbabilities"]}, 
    Flatten@Table[
      If[sm[[i, j]] != 0, DirectedEdge[i, j] -> sm[[i, j]], {}], {i, 
       statesNumber}, {j, statesNumber}]], ImageSize -> Medium]

VisualizeOneMarkovProcess[\[CurlyPhi]]

Then we calculate the mean of the FirstPassageTime to the absorb state.

\[ScriptCapitalD] = FirstPassageTimeDistribution[\[CurlyPhi], 3];
mypdf = PDF[\[ScriptCapitalD], k]
(* \[Piecewise] 2^(-1+k) 3^-k   k>0    0    True *)

Mean[\[ScriptCapitalD]]   (* 3 *)

So the answer is $\color{blue}{3}$

$\endgroup$
1
  • $\begingroup$ Code-only answers are useful but not really on topic here on CV when they have contain statistical explanation or insight: consider posting your Mathematica solutions on the Mathematica site instead. $\endgroup$
    – whuber
    Commented Mar 5 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.