% LMcs060301_4th.m
% Larsen & Marx Case Study 6.3.1 (2006, p. 441)
% Point Spread example
% Point spreads are set so 50% of teams beat the spread
% During one period 67 of 124 teams beat the spread
% What is the probability that 67/124 could have been
% observed by chance if the true p of beating the spread
% is 0.5?
X=67;
n=124;
p=0.5;
% Check Demoivre-Laplace rule, Larsen & Marx (2006, Equation 6.3.1)
OUT=demoivre(n,p);
if OUT==1
    fprintf('The DeMoivre-Laplace rule is met, Normal approximation probably ok\n');
else
    fprintf('The DeMoivre-Laplace rule not met, Normal approximation not ok\n');
end
usebinomial=0;  % Will perform the approximate test
[p2tailed,exact,zval]=onesamplebinom(n,X,p,usebinomial);
fprintf(...
    'Using the normal approximation for the 1-sample binomial, z=%6.4f and 2-tailed p=%6.4f\n',...
    zval,p2tailed);
usebinomial=1;
[p2tailed,exact]=onesamplebinom(n,X,p,usebinomial);
fprintf(...
    'Using the binomial pdf for the 1-sample binomial, 2-tailed p=%6.4f\n',...
    p2tailed);