# Sheldon Ross 10: Exercise 3.90

Question: The number of accidents in each period is a Poisson random variable with mean 5. With Xn, n ≥ 1, equal to the number of accidents in period n, find E[N] when

1. N = min(n: Xn−2 = 2, Xn−1 = 1, Xn = 0);
2. N = min(n: Xn−3 = 2, Xn−2 = 1, Xn−1 = 0, Xn= 2).

Analytical Solution

1. This is straight-forward find the probability for having 0,1,2 sequence without gaps. Then, the reciprocal of that probability gives the expected number
• p[ N ] = Poission[ 5, 2 ] * Poisson [ 5,1 ] * Poisson[ 5,0 ]
• where 5 is the mean and 0, 1, and 3 are the number of accidents
• E[ N ] = 1P[5,2]*P[5,1]*P[5,0] ≅ 52304.3
• shortened the notation of the Poisson for convenience
2. Similarly,
• E [ N ] =
• 1P[5,2]*P[5,1]P[5,0]*P[5,2] + 1P[5,2] ≅ 621023

Simulation Solution

1. For this part, I have run the simulation a few times and each of the following numbers is a batched mean of 10 runs each. As you can see, this simulation is computationally very very extensive. Calculation-wise, the expected number of Poisson outcomes needed to get the pattern 100 times is 100*E[X] ≅ 100*52304.3 ≅ 5230430 ( ≅ 5.2 million 😮)
• 50760.5
• 65945.6
• 42563.8
• 42455.9
• 38466.3
• 56531.4
• 69722.8
• 63894.2
• 69857.1
• 30711.9
2. The following are the batched means as above with 10 outcomes each per batch. Calculation-wise, to get the required pattern about a 100 times it would take 100*E[X] ≅ 100*621023 ≅ 62102300  ( ≅ 62 million 😮😮😮)
• 735152
• 772370
• 863976
• 890434
• 1068680
• 778421
• 595726
• 885605
• 358737
• 504508

Code

```Table[ParallelTable[
Module[{accidents = RandomVariate[PoissonDistribution, 3],
i = 3},
While[True,
accidents =
Rest[accidents] ~ Join ~ {RandomVariate[PoissonDistribution]};
i += 1;
If[accidents == {0, 1, 2}, Break[]]
];
i
], 10] // Mean // N, 10]

Table[ParallelTable[
Module[{accidents = RandomVariate[PoissonDistribution, 4],
i = 4},
While[True,
accidents =
Rest[accidents] ~ Join ~ {RandomVariate[PoissonDistribution]};
i += 1;
If[accidents == {2, 1, 0, 2}, Break[]]
];
i
], 10] // Mean // N, 10]```

End of the post 😉

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.