# Sheldon Ross 10: Exercise 3.54

Question: A coin is randomly selected from a group of ten coins, the nth coin having a probability n10 of coming up heads. The coin is then repeatedly flipped until a head appears. Let N denote the number of flips necessary. What is the probability distribution of N? Is N a geometric random variable? When would N be a geometric random variable; that is, what would have to be done differently?

Analytical Solution

We will solve for both the probability as well as the expected value. We can solve this using conditional expectation. One could follow an approach as outlined below.

E[N] = E[ E[ N|Coin=n ] ]

⇒ E[N] = Summation( E[ N|Coin=n ] ] P{ Coin=n } )

⇒ E[N] = Summation( 1i10 110 ) ≅ 2.92897

Next part

P{ N=t } = P{ N=t | Coin=n } P{ Coin=n  }

⇒ P{ N=t } = Summation over n : n10 (1-n10)(t-1) 110

And no, N would not be a geometric variable unless of course all the coins have the same probability or the same coin is deliberately chosen every single time (that would be a lot of bias ;))

Simulation Solution

The plots are self explanatory and the code required for them is provided below in the code section.

Code

```Module[{probabilities = Divide[Range@10, 10]},
Labeled[Histogram[
Mean /@ Partition[(RandomVariate[GeometricDistribution[#]] + 1) & /@
RandomChoice[probabilities, 1000000], 100], {0.05},
Frame -> True,
FrameLabel -> Style["\[Mu](N) \[Congruent] E(N)", 15, Lighter@Red],
ImageSize -> 788],
Style["Means calculated for batches of size 15", Lighter@Red, 20],
Top]
]

Module[{probabilities = Divide[Range@10, 10], data},
data = KeySort@
Counts[(RandomVariate[GeometricDistribution[#]] + 1) & /@
RandomChoice[probabilities, 10000]];
Labeled[BarChart[data,
ChartLabels ->
Placed[{Keys@data,
Rotate[#, Divide[\[Pi], 2]] & /@ (Values@data)}, {Below,
Above}], Frame -> True, ImageSize -> 788],
Style["Counts of the number of turns taken for a pass", Lighter@Red,
20], Top]
]```

End of the post 🙂

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.