%
%  math495/stat490 -- 16 oct 03 -- djm

%  w07unifA.m:  uniform rv histogram

clear

%  initialize settings
rand('state',2914814)
Nrvs = 500;  Nex = 1;  Nbins = 10;

%  plot histogram
figure(1);  clf;  hold on
db = 1/Nbins;
bins = db/2:db:1-db/2;  ePDF = zeros(1,Nbins);

%  uniform random variables
for j=1:Nex
    rvs = rand(Nrvs,1);
    ePDF = hist(rvs,bins)/(Nrvs*db);  
    plot(bins,ePDF,'r-o')
end

plot([0 1],[1 1],'b')
title(['\bf histogram for (N = ' num2str(Nrvs) ' rvs)'])
xlabel(['\bf x_k (M = ' num2str(Nbins) ' bins)'])
ylabel(['\bf ePDF via simple histogram (' num2str(Nex) ' simulations)'])
axis([0 1 0 max(ePDF(:))])

%plot([0 1],[1 1]-2*sqrt((Nbins-1)/Nrvs),'b--')
%plot([0 1],[1 1]+2*sqrt((Nbins-1)/Nrvs),'b--')

