This example has already been done neatly in the textbook, but this is an attempt to explain the ideas visually.
Question: “Suppose that an airplane engine will fail, when in flight, with probability 1−p independently from engine to engine; suppose that the airplane will make a successful flight if at least 50 percent of its engines remain operative. For what values of p is a four-engine plane preferable to a two-engine plane?”
Consider the check and cross marks to be the engines. A check indicates a functional engine and a cross indicates a failed engine.
Module[{marks = {Style["\[Checkmark]", Darker@Green], Style["✗", Red]}, replacer, configs, engines = 2},
replacer[list_List] := Table[If[list[[n]] == 1, marks[[1]], marks[[2]]], {n, 1, Length@list}];
configs = (replacer /@ Union@SortBy[Select[Tuples[{0, 1}, engines], Plus @@ # >= 0.5 engines &], Plus @@ # &]);
TableForm[Table[Apply[StringJoin,ToString[#, StandardForm] & /@ configs[[n]]], {n, 1, Length@configs}]]]
Module[{marks = {Style["\[Checkmark]", Darker@Green], Style["✗", Red]}, replacer, configs, engines = 4},
replacer[list_List] := Table[If[list[[n]] == 1, marks[[1]], marks[[2]]], {n, 1, Length@list}];
configs = (replacer /@ Union@SortBy[Select[Tuples[{0, 1}, engines], Plus @@ # >= 0.5 engines &], Plus @@ # &]);
TableForm[Table[Apply[StringJoin,ToString[#, StandardForm] & /@ configs[[n]]], {n, 1, Length@configs}]]]
Module[{marks = {Style["\[Checkmark]", Darker@Green], Style["✗", Red]}, replacer, configs, engines = 6},
replacer[list_List] := Table[If[list[[n]] == 1, marks[[1]], marks[[2]]], {n, 1, Length@list}];
configs = (replacer /@ Union@SortBy[Select[Tuples[{0, 1}, engines], Plus @@ # >= 0.5 engines &], Plus @@ # &]);
TableForm[Partition[Table[Apply[StringJoin, ToString[#, StandardForm] & /@ configs[[n]]], {n, 1, Length@configs}], 7]]]
Module[{marks = {Style["\[Checkmark]", Darker@Green], Style["✗", Red]}, replacer, configs, engines = 8},
replacer[list_List] := Table[If[list[[n]] == 1, marks[[1]], marks[[2]]], {n, 1, Length@list}];
configs = (replacer /@ Union@SortBy[Select[Tuples[{0, 1}, engines], Plus @@ # >= 0.5 engines &], Plus @@ # &]);
TableForm@Partition[Join @@ {Table[Apply[StringJoin,ToString[#, StandardForm] & /@ configs[[n]]], {n, 1, Length@configs}],
Table[Style[StringJoin @@ Table["\[Checkmark]", engines], White], 5]}, 8]]
Mathematical modelling is straightforward since the objective is clear. For a plane with 2n engines, we need at-least n engines working. Total probability for a successful flight is \[\underset{n}{\Sigma} C_{k} p^{k}(1-p)^{2n-k} : k \ge n\]
The question asks the probability for which the 2-Engine Plane is preferable to the 4-Engine Plane. For this we need \(2n\) be equal to 2 and 4. The expansion results in the following. \[2p(1 − p) + p^{2} = 6p^{2} + (1 − p)^{2} + 4p^{3}(1 − p) + p^{4}\]
Solving for \(p\), we get the following solutions. \(p = 0; p = 0.66667; p = 1\). The code for solving that is pasted below.
Module[{n = 4},
Solve[
Sum[Binomial[2, i] Power[p, i] Power[1 - p, 2 - i], {i, 1, 2}] ==
Sum[Binomial[n, i] Power[p, i] Power[1 - p, n - i], {i, 0.5 n, n}],p]
]
Graphically, and comparing the 2-Engine Plane to the 4-Engine planes, we see a nice pattern taking shape.
Module[{maxE = 4},
Plot[Evaluate@
Table[Sum[
Binomial[r, i] Power[p, i] Power[(1 - p), r - i], {i, 0.5 r, r}], {r, 2, maxE, 2}], {p, 0, 1},
ImageSize -> 575,
AxesLabel -> {"p", "p for 50% or more engines"},
PlotLegends -> Table["No. of Engines = " <> ToString[n], {n, 2, maxE, 2}],
Frame -> True]
]
Module[{maxE = 16},
Plot[Evaluate@
Table[Sum[
Binomial[r, i] Power[p, i] Power[(1 - p), r - i], {i, 0.5 r, r}], {r, 2, maxE, 2}], {p, 0, 1},
ImageSize -> 575,
AxesLabel -> {"p", "p for 50% or more engines"},
PlotLegends -> Table["No. of Engines = " <> ToString[n], {n, 2, maxE, 2}],
Frame -> True]
]