function OUT=demoivre(n,p)
% format OUT=demoivre(n,p)
% Evaluates the DeMoivre-Laplace rule for the adequacy
% of the Normal approximation to the binomial distribution
% See Theorem 6.3.1, 440 (4th ed) p. 376 (3rd ed) in Larsen & Marx
% returning a 1 if the normal approximation is adequate.
% input:  n=sample size
%         p=proportion
% output: 1 Normal approximation to the binomial pdf adequate
%         0 Normal approximation to the binomial pdf inadequate
% Reference: Larsen & Marx (2001, p. 268); Larsen & Marx (2006, p. 440)
% Used in Case Study 6.3.1
% written by Eugene.Gallagher@umb.edu

OUT=0;
if n*p-3*sqrt(n*p*(1-p))>0 & n*p+3*sqrt(n*p*(1-p))<n
    OUT=1;
end