Sheldon Ross 10: Exercise 3.50

Question: There are three coins in a barrel. These coins, when flipped, will come up heads with respective probabilities 0.3, 0.5, 0.7. A coin is randomly selected from among these three and is then flipped ten times. Let N be the number of heads obtained on the ten flips.

  1. Find P{N = 0}.
  2. Find P{N = n}, n = 0, 1, . . . , 10.
  3. Does N have a binomial distribution?
  4. If you win $1 each time a head appears and you lose $1 each time a tail appears, is this a fair game? Explain.

Analytical Solution

This is an interesting problem for both the simulation and the calculation.

  • 1. For the general solution,see the next line
  • 2. We will solve the general case and would take care of part 1
    • For the problem, simply apply conditional probability theorem and substitute n with the integer (0 thru 10) to get the answer that you need

P{N=n} = P{ N=n|CoinA } * P{ CoinA } + P{ N=n|CoinB } * P{ Coin} + P{ N=n|CoinC } * P{ Coin}

P{N=n} = Bimoial[10, n] 0.3n 0.710-n * 13 + Binomial[10, n] 0.5n 0.510-n * 13 + Binomial[10, n] 0.7n 0.310-n * 13

  • 3. Nope since the system becomes a binomial after a previous round of selection
  • 4. P{Win} = P{ head($) } = P{ head($)|CoinA } * P{ CoinA } + P{ head($)|CoinB } * P{ Coin} + P{ head($)|CoinC } * P{ Coin}
    • 0.3 * 13 + 0.5 * 13 + 0.7 * 13 = 0.5

Simulation Solution

This is a fairly simple simulation give the problem. I have done the Mathematica implementation of this problem. The plots of the parts 2 and 4 are pasted below. The code for the same is also presented in the next section.


Code

Module[{outcomesMeta = {}},
  Table[Module[{outcomes, turns = 10000},
    outcomes =
        ParallelTable[
          Module[{coin := RandomChoice[{0.3, 0.5, 0.7}], coinTemp},
            coinTemp = coin;
            Count[RandomChoice[{coinTemp, 1 - coinTemp} -> {1, 0}, 10], 1]],
          turns];
    outcomes = {#, N@Divide[Count[outcomes, #], turns]} & /@
        Range[0, 10];
    AppendTo[outcomesMeta, outcomes];
  ], 200];

  ListLinePlot[outcomesMeta, Frame -> True, ImageSize -> 788,
    InterpolationOrder -> 2,
    PlotStyle -> {{PointSize@0.004, Thickness@0, Darker@Green,
      Opacity@0.1}},
    GridLines -> {Range @@ {0, 10, 0.5}, Range @@ {0, 0.2, 0.02}},
    FrameTicks -> {Range @@ {0, 10, 1}, Range @@ {0, 0.2, 0.02}},
    PlotRange -> {Automatic, {0, 0.2}}, AspectRatio -> 0.5,
    PlotLabel -> "P{N=n}"]
]


Module[{simulation},
  simulation =
      Module[{turns = 10000, coin := RandomChoice[{0.3, 0.5, 0.7}],
        coinTemp},
        Mean /@
            ParallelTable[coinTemp = coin;
            RandomChoice[{coinTemp, 1 - coinTemp} -> {1, 0}], turns, 100]
      ];
  Histogram[simulation, {0.01}, ImageSize -> 788, Frame -> True,
    GridLines -> None, AspectRatio -> 0.5,
    PlotLabel -> "Distribution of : P{X=heads} or P{X=$$$}"]
]

End of the post 😉


.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.