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

gamprod_pdf(x, a1, a2)
% gamprod_pdf.m - evaluates a Gamma Product Probability Density.
%   See "Continuous Univariate Distributions", Johnson, Kotz & Balakrishnan,
%   Vol. 2, J. Wiley, 1995, p.353.
%
%       Vector Forms of PDF!!!
%
%  Created by Jim Huntley,  10/20/08
%

function[pdf] = gamprod_pdf(x, a1, a2)

%persistent coef a1pa2 a1ma2

%if(isempty(coef))
    a1pa2 = a1 + a2;
    a1ma2 = a1 - a2;
    coef = exp(log(2) - gammaln(a1) - gammaln(a2));
%end

pdf = coef .* x.^(0.5*a1pa2-1) .* besselk(a1ma2,2.*sqrt(x));

return



Contact us