%
%  math495/stat490 -- 29 sept 03 -- djm
%
%  w05cl.m:  

close all;  clear

%  parameters
Nsum = 20;  Ndata = 1000;  mu = 1/2;  s2 = 1/12;

%  uniform rv's
x_rv = rand(Nsum,Ndata);
c_rv = (sum(x_rv)-Nsum*mu)/sqrt(s2*Nsum);

%  histogram

db = 1/4;  bins = -4:db:4;

c_hist = hist(c_rv,bins);  bar(bins,c_hist,'w');
hold on
plot(bins,(Ndata/sqrt(2*pi))*exp(-bins.^2/2)*db,'r*-');

title(['\bf central limit theorem demo (n=' num2str(Nsum) ')'])
xlabel('\bf c_n bins')
ylabel('\bf # of occurences')