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

chisqprod_pdf(x, nu1, nu2)
% chisqprod_pdf.m - evaluates a Chi-Square Product Probability Density.
%   See "Continuous Univariate Distributions", Vol.1, Johnson, Kotz, and Balakrishnan,   
%   J. Wiley, 1995, p.452.
%
%       Vector Form of PDF!!!
%
%  Created by Jim Huntley,  10/07/08
%

function[pdf] = chisqprod_pdf(x, nu1, nu2)

%persistent exp1 exp2 arg1 glohn1 glohn2

%if(isempty(arg1))
    exp1 = 0.25*(nu1+nu2)-1;
    exp2 = (0.5*(nu1+nu2)-1) * log(2);
    arg1 = 0.5*(nu1-nu2);
    glohn1 = gammaln(0.5*nu1);
    glohn2 = gammaln(0.5*nu2);
%end

pdf = exp(exp1*log(x) + log(besselk(arg1,sqrt(x))) - (exp2 + glohn1 + glohn2));

return



Contact us