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

binpoismix_pdf(n, p, nk, theta)
% binpoismix_pdf.m - evaluates a Binomial Poisson Mixture Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.365, 2005. 
%
%  Created by Jim Huntley,  11/28/06
%

function [pdf] = binpoismix_pdf(n, p, nk, theta)

%persistent emtheta jlim

%if(isempty(jlim))
    jlim = 10*theta;   
    emtheta = exp(-theta);
%end

% Initializations.
coef = binomial_coef(nk,n);
pn = p^n;
ompnkmn = (1-p)^(nk-n);

sum1 = 0;
% Calculate PDF.
for jk = 1:jlim
    sum1 = sum1 + exp(log(theta^(jk-1)) - gammaln(jk));
end

pdf = sum1 * coef * pn * ompnkmn * emtheta;

return


Contact us