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

dblpois2_pdf(n, lambda, mu)
% dblpois2_pdf.m - evaluatess a Double Poisson 2 Probability Density.
%   See "An Introduction to Probability Theory", P.A.P. Moran,
%   Oxford, p.85, 1967.
%
%  Created by Jim Huntley,  10/9/08
%

function [pdf] = dblpois2_pdf(n, lambda, mu)

%persistent coef lglemmu

%if(isempty(coef))
    coef = exp(-lambda);
    lglemmu = log(lambda * exp(-mu));
%end

for jn = 1:size(n,2)
    sums = 0;
    for js = 1:n(jn)+1
        s = js - 1;
        sums = sums + exp(s*lglemmu + (n(jn)-s)*log(mu*s+eps) - (gammaln(s+1)+gammaln(n(jn)-s+1)));
    end
    pdf(jn) = coef * sums;
end

return


Contact us