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

trigamma_pdf(n, c)
% trigamma_pdf.m - evaluates a Trigamma Probability Density.
%   %   See "Random Variate Generation for the Digamma and Trigamma Distributions", 
%   L. Devroye, McGill, 1991.
%
%   Created by:     J. Huntley,  07/15/05
%

function[pdf] = trigamma_pdf(n, c)

%persistent gamlnc lpsinc

%if(isempty(gamlnc))
    gamlnc = gammaln(c);
    lpsinc = log(psin(1,c));
%end

lnpochc = gammaln(c+n) - gamlnc; 
pdf = exp(gammaln(n) - (log(n) + lnpochc + lpsinc));

return

Contact us