Sheldon Ross 10: Exercise 3.73

Question: Suppose that we continually roll a die until the sum of all throws exceeds 100. What is the most likely value of this total when you stop?


Analytical Solution

N/A


Simulation Solution

From the simulation, it is apparent that the most likely value that we obtain is 101.


Code

Module[{simulation, runs = 100000},
  simulation =
      KeySort@Counts[
        Table[Module[{sum = 0, roll := RandomChoice[Range[6]]},
          While[True,
            sum += roll;
            If[sum > 100, Break[]]
          ];
          sum
        ], runs]];
  Framed@BarChart[simulation,
    ChartLabels ->
        Placed[{Values@simulation, Keys@simulation}, {Above, Below}],
    Frame -> True, ImageSize -> 788,
    PlotLabel ->
        "Distribution for sums for " <> ToString[runs] <> " runs"]
]

End of the post 🙂


.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.