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

genlam_cdf(xv,p_value)
% genlam_cdf.m - Tukey's Generalized Lambda Cumulative Distribution Function.
%                http://www.maths.1th.se/help/R/.R/library/gld/html/GeneralizedLambdaDistribution.html
%                SEE WRITE-UP FOR PERMISSIBLE COMBINANATIONS OF PARAMETER VALUES!!!
%
%   created by:  J. Huntley,  10/25/06.
%
%   Vector Form of CDF.
%

function [cdf,fhold] = genlam_cdf(xv,p_value)

% Initializations.
lambda1 = p_value(1);
lambda2 = p_value(2);
lambda3 = p_value(3);
lambda4 = p_value(4);
rand('state',0);
nsamples = size(xv,2);

% Evaluate PPF for evenly-spaced CDF values on [0,1].
xhold = rand(nsamples,1);
fhold = lambda1 + ((xhold.^lambda3 - 1)./lambda3 - ((1-xhold).^lambda4 - 1)./lambda4)./lambda2;    
fmin = min(fhold);
fmax = max(fhold);

% Sort "range" values of PPF into "domain" order.
[xsort, index] = sort(xhold);
fsort = fhold(index);

% Interpolate CDF values to uniform spacing, xi.
xi = fmin:(fmax-fmin)/(nsamples-1):fmax;
cdf = interp1(fsort,xsort,xi,'linear');

return

Contact us