clear
echo on
%Solution to Problem 13
%
%In this problem we are asked to analyze a set of data, 
%measurements of the diameter of particles using a 
%video microscope.  This is a problem which occurs 
%fairly often in our laboratory!  We have the data:

dia=[51.1
        52.9
        54.2
        52.3
        46.7
        49.0
        54.3
        54.1
        49.1
        53.9]
%which is the easy way of putting it into the computer.
pause
%For part a we are asked to compute the mean and an
%unbiased estimate of the population standard deviation:
n=length(dia)
mean=sum(dia)/n
variance=sum(dia.^2-mean^2)/(n-1)
%Thus we have an estimate of the standard deviation:
popsd=variance^0.5
pause
%For part b we want the 95% confidence interval of the mean.
%This is roughly the +- 2sigma interval, where we now use
%the random error in the mean rather than the population sd:
meansd=popsd/n^.5
interval=[mean-2*meansd,mean+2*meansd]
pause
%For part c we are asked to determine how many particles
%we should look at to get a desired level of accuracy - a common
%problem in experimental design!  This is easily estimated from
%the population standard deviation:
nobs=((2*popsd)/(0.01*abs(mean)))^2
pause
%For the final part there is no one right answer.  In general it
%doesn't make sense for us to reduce random error to a level
%much smaller than systematic error, because there is relatively
%little gain - the accuracy of the final answer is dominated by the
%systematic error.  On the other hand, you would probably want
%random error not to be large with respect to systematic error - 
%unless, of course, you don't need all that accurate a result, or 
%unless the measurements are really difficult and expensive to do.
%I would, in general, pick a number of observations which cuts
%random error down so that it is somewhat less than systematic
%error, if possible.  Thus, I would probably use the number of
%observations determined for part c, although the benefit from the
%last 3/4 of these observations really doesn't improve our estimate
%all that much...