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

distgam_pdf(x, a, d, m, p)
% distgam_pdf.m - evaluates a Distended Gamma Probability Density.
%   See "A Beta Warning Time Distribution and a Distended Beta Distribution",
%	H.W. Block & B.R. Rao, Indian J. of Stat., V.35, Series B, Pt.1,1973, p.79.  
%
%  Created by Jim Huntley,  01/05/09
%

function[pdf] = distgam_pdf(x, a, d, m, p)

%persistent mm1 dmmm1 coef ny ymax

%if(isempty(coef))
    mm1 = m - 1;
    dmmm1 = d - m - 1;
    coef = p * m / (gamma(d/p)*a^d);
    ny = 1000;
    yscale = 1;
    ymax = x(end) * yscale;
%end

for jx = 1:size(x,2)
    ymin = x(jx);
    dy = (ymax-ymin) / (ny-1);
    y = ymin:dy:ymax;
    kern = y.^dmmm1 .* exp(-(y./a).^p);
    inty = simps(kern) * dy;
    pdf(jx) = coef * x(jx)^mm1 * inty;
end

return



Contact us