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

cmpdpois_pdf(n, lambda, mu)
% cmpdpois_pdf.m - generates a Compound Poisson Density.
%   See "Compound Poisson Distributions", Handbook on Statistical 
%   Distributions, C. Walck, U. Stockholm, 10 September, 2007.    
%
%  Created by Jim Huntley,  05/31/11
%

function [pdf] = cmpdpois_pdf(n, lambda, mu)

llambda = log(lambda);
coef = exp(-lambda);

kmax = round(max(7,5 * lambda));
sumn = 0;       
for jk = 1:kmax
    k = jk - 1;
    sumn = sumn + exp(n*log(k*mu+eps) - k*mu + k*llambda - gammaln(n+1) - gammaln(k+1));
end
pdf = coef * sumn;

return

Contact us