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

negbindel_pdf(n, m, p, k)
% negbindel_pdf.m - evaluates a Negative Binomial Delta Probability Density.
%   See "The Branching Process Method in Lagrange ...", L. Devroye, web.
%
%  Created by Jim Huntley,  8/26/04
%

function [pdf] = negbindel_pdf(n, m, p, k)

%persistent logk logp logomp

%if(isempty(logk))
    logk = log(k);
    logp = log(p);
    logomp = log(1-p);
%end

%pdf = k * gamma(m*n+n-k) * p^(n-k) * (1-p)^(m*n) / (n * gamma(n-k+1) * gamma(m*n)); 
pdf = exp(logk + gammaln(m*n+n-k) + (n-k)*logp + (m*n)*logomp - ...
      (log(n) + gammaln(n-k+1) + gammaln(m*n)));   

return

Contact us