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

genhypfac_pdf(n, N, a, m)
% genhypfac_pdf.m - evaluates a Generalized Hypergeometric Factorial Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.435, 2005. 
%
%  Created by Jim Huntley,  02/07/07
%

function [pdf] = genhypfac_pdf(n, N, a, m)

gamlnNp1 = gammaln(N+1);
gamlnnp1 = gammaln(n+1);
gamlnmp1 = gammaln(m+1);
loga = log(a);

jsum = 0;
for ji = 1:m-n+1
    ii = ji - 1;
    jsum = jsum + (-1)^ii * exp(gamlnmp1 + gammaln(N-n-ii+1) + (n+ii)*loga - ...
        (gamlnnp1 + gammaln(ii+1) + gammaln(m-n-ii+1) + gamlnNp1));
end
pdf = jsum;

return


Contact us