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

hosking_cdf(xv,p_value)
% hosking_cdf.m - Hosking Cumulative Distribution Function.
%                "Continuous Univariate Distributions", Johnson, Kotz, & Balakrishnan,
%                J. Wiley, V. 1, p.44, 1995.
%
%   created by:  J. Huntley,  10/25/06.
%
%   Vector Form of CDF.
%

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

% Initializations.
alpha = p_value(1);
bet = p_value(2);
gam = p_value(3);
delta = p_value(4);
xi = p_value(5);
%xv(end) = xv(end) - 0.000001;
rand('state',0);
nsamples = size(xv,2);

% Evaluate PPF for evenly-spaced CDF values on [0,1].
xhold = rand(nsamples,1);
fhold = xi + (alpha/bet) .* (1 - (1-xhold).^bet) - (gam/delta) .* (1 - (1-xhold).^(-delta));
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