% LMex040204_4th.m
% Example 4.2.4 Eating bug parts
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu, 12/12/10, revised 1/12/11
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% This is a simple application of the Poisson cumulative distribution
% function and Poisson pdf
% The FDA Food Detection Action Limit for peanut butter is 30 insect
% fragments per 100 grams. If your peanut butter snack weighs 20 grams,
% what is the probability that you'll ingest 5 or more insect parts.
% Calculate lambda, the expected number of insect parts per 20 grams.
lambda=30/100*20;
% solve using the Poisson cumulative distribution function.
P=1-poisscdf(4,lambda);
fprintf(...
'The probability that a 20-g snack contains 5 or more insect parts is %5.3f.\n',P)
% The problem could also be solved exactly using the Poisson pdf.
k=0:4;
P2=1-sum(poisspdf(k,lambda));
fprintf(...
'The probability that a 20-g snack contains 5 or more insect parts is %5.3f.\n',P2)