% LMcs060302_4th.m
% Larsen & Marx Case Study 6.3.2 (2001, p. 377-379; 2006 p 442-443)
% Example of a one-sided binomial test
% Written by Eugene.Gallagher@umb.edu. Written 2003, revised 3/8/11
% Do people postpone dying until their birthdays?
X=60; n=747; p=3/12;
% Check Demoivre-Laplace rule
OUT=demoivre(n,p);
if OUT==1
    fprintf(...
        'DeMoivre-Laplace rule is met, Normal approximation probably ok\n');
else
    fprintf(...
        'DeMoivre-Laplace rule Violated, Normal approximation not ok\n');
end
usebinomial=0;
[p2tailed,exact,zval]=onesamplebinom(n,X,p,usebinomial);
p1tailed=p2tailed/2;
fprintf(...
    'Normal approximation for the 1-sample binomial test, z=%6.4f, 1-tailed p=%11.4e\n',...
    zval, p1tailed);
Lowertailp=sum(binopdf(0:X,n,p));
fprintf(...
    'Using the binomial pdf, Lower Tail exact p=%11.4e\n',...
    Lowertailp);