Sheldon Ross 10: Exercise 3.56

Question: Data indicate that the number of traffic accidents in Berkeley on a rainy day is a Poisson random variable with mean 9, whereas on a dry day it is a Poisson random variable with mean 3. Let X denote the number of traffic accidents tomorrow. If it will rain tomorrow with probability 0.6, fin

  1. E[X]
  2. P{ X = 0 }
  3. X = Var(X)

Analytical Solution

  1. E[X] = E[E[X|weather]] = E[X|rain] P{rain} + E[X|no_rain] P{no_rain} = 9*0.6 + 3*0.4 = 6.6
  2. P{X=0} = P{X=0|rain} P{rain} + P{X=1|no_rain} P{no_rain} =(e-9 900! 0.6)+(e-9 900! 0.4) ≅ 0.0199889
  3. E[X2] = E[E[X2|weather]] = E[X2|rain] P{rain} + E[X2|no_rain] P{no_rain} = (92 + 9)*0.6 + (32 + 3) = 58.8

Simulation Solution

Observations: Because two types of the distributions that are possible depending on whether it is a rainy day or not a rainy day, we can observe the same in the plot below. Observe two peakts that are happening at 9 and 3. This are also the means of the two poisson distributions.


Code

Module[
  {accidents :=
      RandomChoice[{0.6, 0.4} -> {RandomVariate[PoissonDistribution[9]], RandomVariate[PoissonDistribution[3]]}]},
  accidents = KeySort@Counts[accidents & /@ Range[1000000]];

  BarChart[
    accidents,
    ImageSize -> 788,
    Frame -> True,
    ChartLabels -> Placed[{Keys@accidents, Rotate[#, Divide[\[Pi], 2]] & /@ (Values@accidents)}, {Below,Above}],
    PlotLabel -> Style["Distribution of the accidents occuring in the city", 20]]
]

End of the post 😀


.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.