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

exthyper_pdf(n, n1, n2, p1, p2, m)
% exthyper_pdf.m - evaluates an Extended Hypergeometric Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.293, 2005. 
%
%  Created by Jim Huntley,  01/04/07
%

function [pdf] = exthyper_pdf(n, n1, n2, p1, p2, m)

%persistent bcn2m theta arg coef

% Initializations.
%if(isempty(arg))
    bcn2m = binomial_coef(n2,m);
    q1 = 1 - p1;
    q2 = 1 - p2;
    theta = p1 * q2 / (q1 * p2);
    arg = n2 + 1 - m;
    coef = 1 / (bcn2m * genHyper([-n1 -m],arg,theta));
%end

% Evaluate PDF.
pdf = coef * binomial_coef(n1,n) * binomial_coef(n2,m-n) * theta^n;      

return

Contact us