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

logzeropois_pdf(n, omega, lambda, phi)
% logzeropois_pdf.m - evaluates a Log Zero Poisson Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, & Kotz, 
%   J. Wiley, 2005, 356. 
%
%  Created by Jim Huntley,  7/09/07
%

function [pdf] = logzeropois_pdf(n, omega, lambda, phi)

%persistent coef ephi pdf0 logphi

%if(isempty(coef))
    coef = log((1-omega) / (-log(1-lambda)));
    ephi = exp(-phi);
    pdf0 = omega + (1-omega)*log(1-lambda*ephi)/(log(1-lambda));
    logphi = log(phi);
%end

pdf = pdf0;
if(n > 0)
    sumj = 0;
    for jj=1:n
        termj = (lambda * ephi / (1-lambda*ephi))^jj;
        summ = 0;
        for jm = 1:jj
            summ = summ + binomial_coef(jj-1,jm-1) * (-1)^(jj-jm) * jm^(n-1);
        end
        sumj = sumj + termj * summ;
    end
    pdf =  exp(coef + n*logphi + log(sumj) - gammaln(n+1));
end
    
return

Contact us