function lognormal03fig1
% Fig. B.3 Book Illustration for LogNormal RNG Simulation (3/2007):
clc % clear variables, but must come before globals, 
%     else clears globals too.
clf % clear figures
fprintf('\nfunction lognormal03fig1 OutPut:')
kfig = 0; mu = 0.0; sig = 0.5;
muln = exp(mu+sig^2/2);
sigln = muln*sqrt(exp(sig^2) -1);
nbins = 150;
fprintf('\n mu=%f; sig=%f; muln=%f; sigln=%f; nbins=%i'...
    ,mu,sig,muln,sigln,nbins);
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;
    y = mu*ones(N,1) + sig*randn(N,1);
    x = exp(y);
    xmean=mean(x);
    xstd=std(x);
    remean=(xmean/muln - 1)*100;
    restd=(xstd/sigln - 1)*100;
    fprintf('\nLognormal Random Deviate (exp(mu+sig*randn)) Test:');
    fprintf('\n fig=%i; m=%2i; N=%i; xmean=%f; xstd=%f;'...
        ,kfig,m,N,xmean,xstd);
    fprintf('\n fig=%i; relerrmean=%f; relerrstd=%f;'...
        ,kfig,remean,restd);
    xmin = min(x); xmax = max(x);
    xbin1 = xmin; xbin2 = xmax; dxbin = (xbin2-xbin1)/nbins;%
    fprintf('\n#bins(x)=%4i; xbin in [%6f,%6f]; dxbin=%10f;'...
        ,nbins,xbin1,xbin2,dxbin)
    xbin = xbin1+dxbin/2:dxbin:xbin2-dxbin/2;
    nx = hist(x,xbin); % Need Center Oriented hist.
    bar(xbin,nx)
    axis tight
    title('Histogram for Lognormal x'...
        ,'Fontsize',44,'FontWeight','Bold');
    ks = [0.4,0.7];  nxmax = max(nx);
    xtext = xmax*(ks(1)-(kfig-1)*0.1); ytext=fix(ks(2)*nxmax);
    textn=['N = ' int2str(N)];
    text(xtext,ytext,textn...
        ,'Fontsize',40,'FontWeight','Bold');
    ylabel('Lognormal Bin Frequency'...
        ,'Fontsize',44,'FontWeight','Bold');
    xlabel('x, Lognormal 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 lognormal03fig1