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

poispear1_int_pdf(n, a, b, t, p, q, nmax)
% poispear1_int_pdf.m - tests a Poisson Pearson I Probability Density.
%   See "Laplace Transforms, Mellin Transforms and Mixed Poisson Processes", 
%   P. Albrecht, Scand. Actuarial J., vol.1, p.58, 1984. 
%
%  Created by Jim Huntley,  06/01/09
%

function [pdf] = poispear1_int_pdf(n, a, b, t, p, q, nmax)

persistent coef logat kterm

if(isempty(coef))
    coef = gamma(p+q) * exp(-a*t) / gamma(p);
    lbmada = log((b-a)/a);
    argt = (a-b) * t;
    logat = log(a*t);
    %Pre-Compute and store k-dependent terms.
    for jk = 1:nmax+1
        k = jk - 1;
        arg1 = p + k;
        arg2 = p + q + k;     
        kterm(jk) =  exp((k*lbmada + gammaln(arg1) - gammaln(arg2) + ...
                     log(genHyper(arg1,arg2,argt))));
    end 
end

sumk = 0;
for jk = 1:n+1
    k = jk - 1;
    sumk = sumk + binomial_coef(n,k) * kterm(jk);
end 
pdf = coef * exp(n*logat + log(sumk) - gammaln(n+1));

return

Contact us