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

leftpois_pdf(n, theta, r1)
% leftpois_pdf.m - evaluates a Left-truncated Poisson Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, 190. 
%
%  Created by Jim Huntley,  7/01/07
%

function [pdf] = leftpois_pdf(n, theta, r1)

sum1 = 0;
for jn = 1:r1
    %sum1 =  sum1 + theta^(jn-1)/factorial(jn-1);
    sum1 =  sum1 + exp((jn-1)*log(theta) - gammaln(jn));
end
%pdf = exp(-theta) * theta^n / ((1 - exp(-theta)*sum1) * factorial(n));
pdf = exp(-theta + n*log(theta) - log(1 - exp(-theta)*sum1) - gammaln(n+1));
    
return

Contact us