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

genneghyp_pdf(n, N, a, b, c, t)
% genneghyp_pdf.m - evaluates a Generalized Negative Hypergeometric Probability Density.
%   See "Univariate Discrete Distributions", Johnaon, Kemp, & Kotz, 
%   J. Wiley, 2005, p.299.
%
%  Created by Jim Huntley,  7/30/07
%
%   Calls:  Jk(k,a,c,t)
%

function [pdf] = genneghyp_pdf(n, N, a, b, c, t)

J1 = Jk(n,a,c,t);
J2 = Jk(N-n,b,c,t);
J3 = Jk(N,a+b,c,t);
pdf = exp(log(binomial_coef(N,n)) + J1 + J2 - J3);    

return

function [val] = Jk(k, a, c, t)

if(k == 0)
    val = 0;
elseif(k > 0)
    val = log(a);
    for jk = 1:k-1
        val = val + log(a+k*t+jk*c);
    end
end

return

Contact us