% LMcs040301_4th.m
% Case Study 4.3.1 ESP P 298 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene Gallagher for EEOS601
% Eugene.Gallagher@umb.edu, http://www.es.umb.edu/edgwebp.htm
% Thirty two students correctly guessed 12,489 times out of 60,000
% when the expected number of successes would be just 12,000. What is
% the probability of this occuring by chance.
k=12489;
n=6e4;
p=1/5;
P1=1-binocdf(k,n,p);
fprintf('\nUsing the binomial cdf, the exact P = %9.7g\n',P1)
X=(12488.5-n*p)/sqrt(n*p*(1-p));
P2=1-normcdf(X);
fprintf('Using the Normal approximation with the continuity \n')
fprintf('correction, the exact P = %9.7g\n',P2)
X=(12489-n*p)/sqrt(n*p*(1-p));
P3=1-normcdf(X);
fprintf('Using the Normal approximation without the continuity \n')
fprintf('correction, the exact P = %9.7g\n',P3)