The problem is from Principles of Statistics by M.G. Bulmer:
In a certain survey of the work of chemical research workers, it was found, on the basis of extensive data, that on average each man required no fume cupboard for 60 per cent of his time, one cupboard for 30 per cent and two cupboards for 10 per cent; three or more were never required. If a group of four chemists worked independently of one another, how many fume cupboards should be available in order to provide adequate facilities for at least 95 per cent of the time?
My approach to solving it has been to enumerate, for the 4 chemists, all the cases in which each requires 0, 1 or 2 fume cupboards. This takes the form of a list like so:
{{0,0,0,0}, {0,0,0,1}, {0,0,0,2}, {0,0,1,0}, {0,0,1,1}, {0,0,2,0},...}
I then compute the probability of each particular case, sort the cases from low to high by number of cupboards required, and finally compute a running cumulative probability:
(* enumerate all the cases, as length-4, base-3 numbers *)
hoods = PadLeft[IntegerDigits[#, 3], 4, 0] & /@ Range[0, 80];
(* compute overall odds per case *)
odds = {0 -> 0.6, 1 -> 0.3, 2 -> 0.1};
data = Table[{
Plus @@ x, x, x /. odds, Times @@ (x /. odds)},
{x, hoods}];
(* sort by number of hoods needed for each case *)
data = Sort[data, #1[[1]] < #2[[1]] &];
(* compute & thread in cumulative probability the N hoods will be enough *)
cumulativeOdds = Accumulate[#[[4]] & /@ data];
data = Flatten[#, 1] & /@ Thread@{Range[1, 81], cumulativeOdds, data};
headings = {"idx", "cum. prob.", "hoods needed",
"hoods per chemist", "prob./chemist", "overall prob."};
Grid[Prepend[data, headings], Frame -> All,
Background -> {None, {51 -> LightRed}}, Spacings -> {1.5, 1.2}]
My question is: is there a more direct way to approach this kind problem, perhaps using higher-level Mathematica features/functions or higher-level concepts from probability?
Followup:
I made a table and graph summarizing Eric Towers' Excellently Simple & Short Solution:
pdf = CoefficientList[(0.6 + 0.3 x + 0.1 x^2)^4, x];
cdf = Accumulate[pdf]; len = Length[pdf];
tbl = Table[{i - 1, pdf[[i]], cdf[[i]]}, {i, 1, len}];
Grid[{{tbl // TableForm, ListPlot[Transpose@tbl[[All, {2, 3}]],
AxesOrigin -> {-1, 0}, DataRange -> {0, len - 1},
ImageSize -> 250]}}, Spacings -> 4]