Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

ztpoissum_pdf(n, nn, m, lambda)
% ztpoissum_pdf.m - evaluates a Zero-Truncated Poisson Sum Probability Density.
%   See "On the Sum of Independent Zero-Truncated Poisson Random Variables",   
%   J. Springael, 8 June 2006. 
%
%  Created by Jim Huntley,  08/30/11
%

function [pdf] = ztpoissum_pdf(n, nn, m, lambda)

%persistent coef llambda

%if(isempty(coef))
    llambda = log(lambda);
    coef = 1 / (exp(lambda)-1)^m;
%end

sumk = 0;
for jk = 1:m+1
    k = jk - 1;
    sumk = sumk + binomial_coef(m,k) * (-1)^k * (m-k)^n;
end
pdf = coef * (exp(log(max(sumk,eps)) + n*llambda - gammaln(n+1)));

return

Contact us