**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

- E[X]
- P{ X = 0 }
- X = Var(X)

**Analytical Solution**

- 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
- P{X=0} = P{X=0|rain} P{rain} + P{X=1|no_rain} P{no_rain} =(
^{e-9 90}⁄_{0!}0.6)+(^{e-9 90}⁄_{0!}0.4) ≅ 0.0199889 - E[X
^{2}] = E[E[X^{2}|weather]] = E[X^{2}|rain] P{rain} + E[X^{2}|no_rain] P{no_rain} = (9^{2}+ 9)*0.6 + (3^{2}+ 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 😀

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.