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

neypois_pdf(n, lambda, phi, rho)
% neypois_pdf.m - evaluates a Neyman Type A Poisson Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, & Kotz,
%   J. Wiley, 2005, p.420.
%
%  Created by Jim Huntley,  7/25/07
%

function [pdf] = neypois_pdf(n, lambda, phi, rho)

%persistent P0 arg larg logrho logphi

%if(isempty(P0))
    arg = exp(-phi);
    larg = log(lambda*arg);
    logrho = log(rho);
    logphi = log(phi);
    P0 = exp(lambda*(arg-1)-rho);
%end

pdf = P0;

if(n > 0)
    sumj = 0;
    for jj = 1:n+1
        sumk = 0;
        j = jj - 1;
        for kk = 1:jj+1
            k = kk - 1;
            sumk = sumk + exp(log(stirling2(j,k)+eps) + (n-j)*logrho + j*logphi + k*larg - (gammaln(n-j+1+eps)+gammaln(jj)));
        end
        sumj = sumj + sumk;
    end
    pdf = P0* sumj;
end

return

Contact us