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

gengam_pdf(x, k, c, a, b)
% gengam_pdf.m - evaluates a Generalized Gamma Probability Density.
%   See "Dataplot Reference Manual, GGDCDF", Aux-206, NIST, 3/25/97.
%
%  Created by Jim Huntley,  8/03/04
%

function [pdf] = gengam_pdf(x, k, c, a, b)

%persistent gamk t1 logc

%if(isempty(gamk))
    gamk = gammaln(k);
    t1 = log(b^(c*k));
    logc = log(c);
%end

%pdf = c*(x-a)^(c*k-1)*exp(-((x-a)/b)^c)/(gamma(k)*b^(c*k));
pdf = exp(logc + log((x-a)^(c*k-1)) + (-((x-a)/b)^c) - (gamk + t1));

return

Contact us