Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

davies_cdf(xv,p_value)
% davies_cdf.m - Davies Cumulative Distribution Function.
%                "A New Family of Non-Negative Distributions, Aust. N. Z.
%                J. Stat 48(1), p.67, R. Hankin and A. Lee, 2006.
%
%                SEE WRITE-UP FOR PERMISSIBLE COMBINANATIONS OF PARAMETER VALUES!!!
%
%   created by:  J. Huntley,  10/25/06.
%
%   Vector Form of CDF.
%

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

% Initializations.
c = p_value(1);
lambda1 = p_value(2);
lambda2 = p_value(3);
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 = c .* xhold.^lambda1 ./ (1-xhold).^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