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

hypnegbin_pdf(n, q, r, theta, nmax)
% hypnegbin_pdf.m - evaluates a Hyper-Negative Binomial Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p. 247, 2005.
%
%  Created by Jim Huntley,  3/22/07
%

function [pdf] = hypnegbin_pdf(n, q, r, theta, nmax)

%persistent coef

%if(isempty(coef))
    coef = 0;
    for j = 1:nmax+1
        term = gammaln(r+j+1) - gammaln(theta+j-1);
        term = exp(term);
        coef = coef + term * q^(j-1);
    end
%end

term = gammaln(r+n+2) - gammaln(theta+n);
term = exp(term);
pdf = term * q^n / coef;

return

Contact us