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

logpois_pdf(n, p, lambda)
% test_logpois.m - tests a Logarithmic Poisson Probability Density.
%   See "Lagrangian Probability Distributions", P.C. Consul & F. Famoye,
%   Birkhauser, 2006, Table 2.4.
%
%  Created by Jim Huntley,  12/03/08
%

function [pdf] = logpois_pdf(n, p, lambda)

%persistent q coef

%if(isempty(coef))
    q = 1 - p;
    coef = (1-lambda) / (-log(q));
%end

sumk = 0;
for k = 1:n
    %sumk = sumk + (p/(lambda*n))^k / (k*gamma(n-k+1));
    sumk = sumk + exp(k*log(p/(lambda*n)) - (log(k)+gammaln(n-k+1)));
end    
pdf =  coef * (n*lambda)^n * exp(-lambda*n) * sumk;       

return

Contact us