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

delaport_pdf(n, alpha, bet, gam)
% delaport_pdf.m - evaluates a Delaporte Probability Density.
%   See "Decompounding Random Sums: A nonparametric approach", M. B. Hansen
%   and S. M. Pitts, Aalborg U., May, 2006.
%
%  Created by Jim Huntley,  7/20/06
%

function [pdf] = delaport_pdf(n, alpha, bet, gam)

%persistent lgam lbet

%if(isempty(lgam))
    lgam = log(gam);
    lbet = log(1/(1+bet));
%end

sum1 = 0;

for jk = 1:n+1
    %sum1 = sum1 + gam^(n-jk+1) * binomial_coef(alpha+jk-2,jk-1) *  ...
    %      (1/(1+bet))^(jk-1) / factorial(n-jk+1);
    sum1 = sum1 + exp((n-jk+1)*lgam + log(binomial_coef(alpha+jk-2,jk-1)) +  ...
          (jk-1)*lbet - gammaln(n-jk+2));  
end

pdf = sum1 * exp(-gam) * (bet/(bet+1))^alpha;

return

Contact us