% LMcs030301_4th.m
% Case Study 3.3.1 Page 151-152 in  
% Larsen & Marx (2006) Introduction to Mathematical Statistics 4th Edition
% Fit of the Poisson distribution to deaths.
% Written 2001, Revised 1/12/11 for EEOS601 by Eugene.Gallagher@umb.edu
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
NumberDead=[0:6]';
NumberDays=[484 391 164 45 11 1 0]';
Proportion=NumberDays/sum(NumberDays)';
lambda=sum(NumberDead.*Proportion);
% See Larsen & Marx (2006) p. 281 on the Poisson distribution
fprintf('The Poisson parameter is %5.3f\n',lambda)
ps = poisspdf(0:1000,lambda)';
plus6=sum(ps(7:end));
ps(7)=plus6;ps(8:end)=[];
NumberDeaths=['0 ';'1 ';'2 ';'3 ';'4 ';'5 ';'6+'];
disp('Deaths Days   P     p(s)')
for i=1:7
fprintf('%3s    %3.0f  %5.3f  %5.3f\n',NumberDeaths(i,:),NumberDays(i), ...
    Proportion(i), ps(i))
end
bar(0:6,[Proportion ps],1,'grouped')
legend('Observed','Poisson Expectation','NorthEast','FontSize',20)
xlabel('Number of Deaths','FontSize',20)
ylabel('Proportion','FontSize',20)
NumberDeaths=['0 ';'1 ';'2 ';'3 ';'4 ';'5 ';'6+'];
title('Case Study 3.3.1','FontSize',22);figure(gcf);