% LMp100306_4th.m
Total=5139
O=zeros(2,1);E=zeros(2,1)
O(1)=1383
O(2)=Total-O(1);
E(1)=1292.1
E(2)=5139-1292.1
chi2=sum((O-E).^2./E);
df=length(E)-1;
fprintf('The chi-square statistic with %1.0f df is %5.2f\n',df,chi2)
criticalval=chi2inv(0.95,df);
if chi2 >=       criticalval
    disp('Reject null')
else
    disp('Fail to reject null')
end
df=length(E)-1;
pvalue=1-chi2cdf(chi2,df)