% LMex070501_4th.m
% Page 503 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu 3/13/11
% What is the minimum n such that the width of the 95% confidence interval
% for sigma^2 is no greater than sigma^2;
Width=(n-1)*s2*(1/chi2inv(alpha/2,n-1)-1/chi2inv(1-alpha/2,n-1));
% So
alpha=0.05;
x = fsolve(@(n) (n-1)*(1/chi2inv(alpha/2,n-1)-1/chi2inv(1-alpha/2,n-1))-1,30)
% x=38.562, so
fprintf(...
'The min n such that the %4.1f%% CI width for sigma^2 < sigma^2 is %2.0f\n',...
100*(1-alpha),ceil(x));