% LMcs070501_4th.m
% Page 502-503 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu, 3/13/11, revised:
% Will solve the easy and easiest way.
X=[249;254;243;268;253;269;287;241;273;306;303;280;260;256;278;344;304;283;310];
[MUHAT,SIGMAHAT,MUCI,SIGMACI] = normfit(X)
df=length(X)-1;
fprintf('The 95%% CI for sigma is %4.2f and %4.2f million years\n',SIGMACI)
% Now find CI using Theorem 7.5.1
alpha=0.05;chi2low=chi2inv(alpha/2,df);
chi2up=chi2inv(1-alpha/2,df);
s2=var(X);s=std(X);
fprintf('The variance is %5.1f and sd is %5.1f million years.\n',s2,s);
Low95s=sqrt(df*s2/chi2up);Up95s=sqrt(df*s2/chi2low);
fprintf('The 95%% CI for sigma is %4.2f and %4.2f million years\n',Low95s,Up95s)

