Probability | Poisson Distribution | Many More Monies


Question

The number of coins that Henry spots when walking to park is a Poisson random variable with mean 6. Each coin is equally likely to be a penny, a nickel, a dime, or a quarter. Henry ignores the pennies but picks up the other coins.

  1. Find the expected amount of money that Henry picks up on his way to park.
  2. Find the variance of the amount of money that Henry picks up on his way to park.
  3. Find the probability that Henry picks up exactly 25 cents on his way to park.

Reference: Sheldon Ross Probability Modelling Edition 10


Solution | Analytical

There are three parts to the problem, and we can approach them systematically. Let us also assign symbols to the coin types for easier reference.

1. Expected amount of money

Expected amount of money is the easiest to solve amongst all the three questions. Let us tackle is systematically

2. Variance of amount of money

\(Var(C_x) = E(N) * Var(C_x) + (E[C_x])^2 * Var(N)\) where \(N\) is the Poisson random variate with \(\lambda = 6\)

Bringing all of the above together, \[Var(C_x) = E(N) * Var(C_x) + (E[C_x])^2 * Var(N) = 6 * 87.5 + 100 * 6 = 1125 \space ¢^2 \]

3. \(P(\Sigma x) = 25¢\)

We will solve this using simulation. Please scroll below


Solution | Simulation

1. Expected amount of money: The following code was used to calculate the mean money collected for \(x\) iterations

coinsCollected := RandomChoice[{0, 5, 10, 25}, RandomVariate[PoissonDistribution[6]]]

simulator[n_] := Module[{simulation}, simulation = Table[coinsCollected, n]; simulation]

Mean[Total /@ simulator[1000]] // N

2. Variance of amount of money: The following code was used to calculate the mean money collected for \(x\) iterations

coinsCollected := RandomChoice[{0, 5, 10, 25}, RandomVariate[PoissonDistribution[6]]]

simulator[n_] := Module[{simulation}, simulation = Table[coinsCollected, n]; simulation]

Variance[Total /@ simulator[1000]] // N

3. \(P(\Sigma x) = 25¢\): The following code was used to probability for \(x\) iterations

coinsCollected := RandomChoice[{0, 5, 10, 25}, RandomVariate[PoissonDistribution[6]]]

iterations = 10000000;

Length[Select[Total /@ simulator[iterations], # == 25 &]]/iterations // N

Visualization

The following code was used for visualization

        
ClearAll[coinsCollected, mapperText, mapperBar, mapperTotal, simulator]

totalTextPosX = 30;
rectOffset = 31;
xScaler = 0.05;

coinsCollected :=
 RandomChoice[{0, 5, 10, 25}, RandomVariate[PoissonDistribution[6]]]

mapperText[y_, list_List] := Module[{counts, keys, values},
  counts = Counts[list];
  MapThread[{{Red},
     Text[Style[#1, {Black, FontSize -> 10}], {#2, y}]} &, {Values@
     counts, Keys@counts}]
  ]
mapperBar[total_, y_] := {Opacity[0.5], Gray,
  Rectangle[{rectOffset, y - 0.05}, {rectOffset + xScaler*total,
    y + 0.1}]}
mapperTotal[total_,
  y_] := {Text[
   Style[StringPadRight[ToString[0.01*total], 4, "0"], {Black,
     FontSize -> 10}], {totalTextPosX, y}]}

simulator[n_] := Module[{simulation},
  simulation = Table[coinsCollected, n];
  simulation
  ]

plot := Module[{simulation, range, length, totals, a, b},
  simulation = simulator[100];
  totals = Total /@ simulation;
  length = Length@simulation;
  Echo[Mean@totals // N];
  range = Range[100/length, 100, 100/length];
  a = Graphics[{MapThread[mapperText[#1, #2] &, {range, simulation}],
     {White,
      Rectangle[{rectOffset, 0}, {rectOffset + xScaler*Max@totals,
        Max@range}]},
     MapThread[mapperTotal[#1, #2] &, {totals, range}],
     MapThread[mapperBar[#1, #2] &, {totals, range}]
     },
    PlotRange -> All, Frame -> True,
    FrameTicks -> {{{0, "x 1¢"}, {5, "x 5¢"}, {10, "x 10¢"}, {25,
        "x 25¢"}, {totalTextPosX, "Total$"}}, Automatic},
    GridLines -> {{0, 5, 10, 25}, Range[100]},
    GridLinesStyle -> {{Thickness[.02], Opacity[0.0],
       Green}, {Thickness[0], Gray, Opacity[0.1]}},
    FrameLabel -> {None, "Iterations"},
    ImageSize -> 800, AspectRatio -> 1.5]
  ]

Export[StringReplace[NotebookFileName[], {".nb" -> ".svg"}], plot]