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

gaus2_ppf(xv, p_value);
% gaus2_ppf.m - numerically estimate Vector Gaussian (normal) Point Percent Function.
%
% created by:  J. Huntley,  09/16/04.
%
% Calls:    'gaus_cdf.m'
%
% Called by:    'distribX.m'
%

function [ppf,fi] = gaus2_ppf(xv, p_value);

rand('state',0);
m = p_value(1);
sigma = p_value(2);
nsamples = 1000;
delta = 2/(nsamples-1);
xv = -1:delta:1;

for js = 1:nsamples                
    xx = xv(js);                            % equally-spaced values of PPF.
    jhold(js) = js;
    xhold(js) = xx;    
    fhold(js) = gaus_cdf(xx,m,sigma);    
end
fmin = min(fhold);
fmax = max(fhold);

figure(10)
plot(xv,fhold);                             % plot CDF.
drawnow;

% Interpolate to find Gaussian PPF at uniform CDF values.
sxv = size(xv,2);
fi = fmin:1/(sxv-1):fmax;                   % equally spaced values of CDF.
ppf = interp1(fhold,xv,fi,'linear');
%ppfmin = min(ppf)
%ppfmax = max(ppf)

figure(11)
plot(fi,ppf);                               % plot PPF.
drawnow;

return

Contact us