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

digamma_pdf(n, a, c)
% digamma_pdf.m - generate random deviates for the Digamma Distibution.
%   %   See "Random Variate Generation for the Digamma and Trigamma Distributions", 
%   L. Devroye, McGill, 1991.
%
%   Created by:     J. Huntley,  07/15/05
%

function[pdf] = digamma_pdf(n, a, c)

%pocha = gamma(a+n) / gamma(a); 
%pochac = gamma(a+c+n) / gamma(a+c);
%psiac = psi(a+c);
%psic = psi(c);
%pdf = pocha / (n * pochac *(psiac - psic));

lnpocha = gammaln(a+n) - gammaln(a); 
lnpochac = gammaln(a+c+n) - gammaln(a+c);
psiac = psi(a+c);
psic = psi(c);
pdf = exp(lnpocha - (log(n) + lnpochac + log(psiac - psic)));

return

Contact us