function uniform03fig1
% Fig. B.1 Book Illustration for Uniform RNG Simulation (3/2007):
clc % clear variables, but must come before globals,
%     else clears globals too.
clf % clear figures
fprintf('\nfunction uniform03fig1 OutPut:')
kfig = 0;
scrsize = get(0,'ScreenSize');
ss = [3.0,2.8,2.6,2.4,2.2,2.0];
for m = 3:2:5
    kfig = kfig+1; figure(kfig);
    N=10^m;
    x=rand(N,1);
    xmean=mean(x);
    xstd=std(x);
    xmin = min(x);
    xmax = max(x);
    remean=(xmean*2-1)*100;
    restd=(xstd*sqrt(12)-1)*100;
    fprintf(...
        '\n fig=%i; m=%2i; N=%i; xmean=%f; xstd=%f; min(x)=%f; max(x)=%f'...
        ,kfig,m,N,xmean,xstd,xmin,xmax);
    fprintf('\n fig=%i; relerrmean=%f; relerrstd=%f;'...
        ,kfig,remean,restd);
    nbins = 30; % min(fix(sqrt(10^m)),101); 
    xmin = 0; xmax = 1;
    xbin1 = xmin; xbin2 = xmax; dxbin = (xbin2-xbin1)/nbins;
    xbin = xbin1+dxbin/2:dxbin:xbin2-dxbin/2;
    fprintf(...
        '\n fig=%i; #bins(x)=%4i; xbin in [%6f,%6f]; dxbin=%10f;'...
        ,kfig,nbins,xbin1,xbin2,dxbin)
    nx = hist(x,xbin); % Need Edge Oriented histc.
    bar(xbin,nx)
    axis tight
    title('Histogram for x = rand(N,1)'...
    ,'Fontsize',44,'FontWeight','Bold');
    ks = [0.1,0.8]; nxmax = max(nx);
    ytext=fix(ks(2)*nxmax); xtext=ks(1);
    textn=['N = ' int2str(N)];
    text(xtext,ytext,textn...
    ,'Fontsize',40,'FontWeight','Bold');
    ylabel('Uniform Bin Frequency'...
    ,'Fontsize',44,'FontWeight','Bold');
    xlabel('x, Uniform rand-Deviate'...
    ,'Fontsize',44,'FontWeight','Bold');
    patchobj = findobj(gca,'Type','patch');
    set(patchobj,'FaceColor','w','EdgeColor','k','linewidth',2);
    set(gca,'Fontsize',36,'FontWeight','Bold','linewidth',3);
    set(gcf,'Color','White','Position'...
        ,[scrsize(3)/ss(kfig) 70 scrsize(3)*0.60 scrsize(4)*0.80]);
end
% End uniform03fig1