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

ghgb3_pdf(n, a, b, c)
% ghgb3_pdf.m - evaluates a Generalized Hypergeometric GHgB3 Probability Density.
%   See "Random Variate Generation for the Digamma and Trigamma Distributions", 
%   L. Devroye, McGill, 1991.
%
%  Created by Jim Huntley,  7/15/05
%

function [pdf] = ghgb3_pdf(n, a, b, c)

%persistent gamabc gamac gambc gama gamb gamc

%if(isempty(gamabc))
    gamabc = gammaln(a+b+c);
    gamac = gammaln(a+c);
    gambc = gammaln(b+c);
    gama = gammaln(a);
    gamb = gammaln(b);
    gamc = gammaln(c);
%end

pocha = (gammaln(a+n) - gama);
pochb = (gammaln(b+n) - gamb);
pochabc = (gammaln(a+b+c+n) - gamabc);
%pdf = gamac*gambc*pocha*pochb / (gamabc*gamc*factorial(n)*pochabc);
pdf = exp(gamac+gambc+pocha+pochb - (gamabc+gamc+gammaln(n+1)+pochabc));

return

Contact us