Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

 

generates random variates from over 870 univariate distributions

logpoismix_pdf(n, bet, theta)
% logpoismix_pdf.m - evaluates a Logarithmic Poisson Mixture Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, & Kotz, 
%   J. Wiley, 2005, 346. 
%
%  Note:    Either PDF is not normalized or the convergence is VERY SLOW!!!
%
%  Created by Jim Huntley,  8/30/07
%

function [pdf] = logpoismix_pdf(n, bet, theta)

%persistent jlim coef logt

%if(isempty(coef))
    jlim = fix(1/bet)+1;
    coef = exp(-theta);
    logt = log(theta);
%end

sum1 = 0;
for jj = 1:jlim
    j = jj - 1;
    bj = bet * j;
    t1 = exp(n*log(bj+eps));
    if(t1 < 1e-10)
        t1 = 0;
    end
    t2 = exp(logt * j);
    t3 = exp(-gammaln(jj));
    t4 = -log(1-bj+eps);
    %sum1 = sum1 + exp(n*log(bj+eps) + logt*j - gammaln(jj)) / (-log(1-bj+eps))
    sum1 = sum1 + t1 * t2 * t3 / t4; 
end
pdf =  coef * sum1 / n; 
    
return

Contact us