Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates


James Huntley (view profile)


generates random variates from over 870 univariate distributions

ncnegbin_pdf(n, a, lambda, ups)
% ncnegbin_pdf.m - evaluates a Non-Central negative binomial Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.242, 2005. 
%  Created by Jim Huntley,  07/31/07

function [pdf] = ncnegbin_pdf(n, a, lambda, ups)

%persistent coef arg

    coef = exp(-lambda) * (1-a)^ups;
    arg = lambda*(1-a);

pdf = coef * a^n * binomial_coef(ups+n-1,n) * genHyper(ups+n,ups,arg);


Contact us