Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

 

generates random variates from over 870 univariate distributions

surf_plot.m
% Plot surface loss data.
x = 1:r_max;
y = emin:estep:emax;
[X,Y] = meshgrid(x,y,bhold3');
figure(1)
surf(X,Y,bhold3')

% Add noise to stabilize fit.
bhold4 = bhold3 + (rand(r_max,esize)-0.5)*0.2;
figure(2)
surf(X,Y,bhold4')

% Assign weights (MANUALLY ITERATE TO MINIMIZE ERROR SURFACE).
w = ones(r_max,esize);
if(use_weights > 0)
	for je = 1:esize        
        for jr = 1:r_max
            if(je > 0.8*esize)
                w(jr,je) = 8;
            end 
            if(jr > 0.8*r_max)
                w(jr,je) = 12;
            end
            if(jr < 0.2*r_max)
                w(jr,je) = 16;
            end
        end
	end
end

% Weighted least-squares fit to polynomial surface.          
[p, S] = polyfit2w(X,Y,bhold4',w',orderx,ordery)


% Computer residuals (errors).
for je = 1:esize
    ee = emin + (je-1)*estep;
    for jr = 1:r_max      
        bherr(jr,je) = polyval2d(p,jr,ee) - bhold3(jr,je);            
    end
end

% Plot Residuals.
yy = emin:estep:emax;
[XX,YY] = meshgrid(x,yy,bherr');
figure(3)
surf(XX,YY,bherr')

Contact us