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

ghfd_pdf(n, theta, alpha, bet, m)
% ghfd_pdf.m - evaluates a Generalized Hypergeometric Factorial Moment Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.298, 2005. 
%
%  Created by Jim Huntley,  02/12/07
%

function [pdf] = ghfd_pdf(n, theta, alpha, bet, m)

%persistent coef ltheta

%if(isempty(coef))
    coef = gammaln(alpha+bet) - gammaln(alpha);
    ltheta = log(theta);
%end

arg = alpha + n;
%pdf = coef * binomial_coef(m,n) * theta^n * gamma(arg) * ...
%      hypergeom([-m+n,arg],arg+bet,theta) / gamma(arg+bet);
pdf = exp(coef + log(binomial_coef(m,n)) + n*ltheta + gammaln(arg) + ...
      log(genHyper([-m+n,arg],arg+bet,theta)) - gammaln(arg+bet));

return


Contact us