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

poiskatz_pdf(n, lambda, alpha, bet, nmax)
% poiskatz_pdf.m - evaluates a Poisson Katz Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, 2005, p.421.    
%
%  Created by Jim Huntley,  8/22/07
%

function [pdf] = poiskatz_pdf(n, lambda, alpha, bet, nmax)

%persistent coef pdf_hold logb P0 ratab

%if(isempty(coef))
    ratab = alpha / bet;
    ombtr = (1 - bet)^ratab;
    logb = log(bet);
    coef = log(lambda * ombtr) - gammaln(ratab);
    P0 = exp(lambda * (ombtr - 1));
    pdf_hold(1:nmax+1) = 0;
%end

if(n == 0) 
    pdf = P0;
    pdf_hold(1) = P0;
elseif(n > 0)
    sumj = 0;
    for jj = 1:n
        j = jj-1;
        sumj = sumj + exp(coef + gammaln(ratab+j+1) + jj*logb + log(pdf_hold(n-jj+1)) - gammaln(j+1));
    end
    pdf = sumj / n;
    pdf_hold(n+1) = pdf;
end

return

Contact us