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

com_pdf(n, lambda, nu)
% com_pdf.m - compute Conway-Maxwell-Poisson Probability Density Function.
%   See "Conjugate Analysis of the Conway-Maxwell-Poisson Distribution", 
%   J. Kadane et al., Carnegie Mellon et al., 6/27/20031.
%
%   Created by:     J. Huntley,  07/15/05
%

function[pdf] = com_pdf(n, lambda, nu)

summax = 100; 
termlim = 1e-6;
sum1 = 0;
for js = 1:summax
    term = exp(log(lambda^(js-1)) - nu*gammaln(js));
    if(js > 3)
        if((term/sum1) < termlim)
            break
        end
    end
    sum1 = sum1 + term;
end

%pdf = lambda^n / ((factorial(n))^nu * sum);
pdf = exp(n*log(lambda) - (nu*gammaln(n+1) + log(sum1)));

return

Contact us