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

mixpoislog_pdf(n, a)
% mixpoislog_pdf.m - evaluates a Mixed Poisson Lognormal Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.324, 2005. 
%
%  Created by Jim Huntley,  7/12/07
%

function [pdf] = mixpoislog_pdf(n, a)

%persistent y dy

%if(isempty(y))
    ny = a * 300;
    ymin = eps;
    ymax = a * 100;
    dy = (ymax-ymin) / (ny-1);
    y = ymin:dy:ymax;
%end

%kern = exp(-y) .* y.^(n-1) .* exp(-0.5.*(log(y)-a).^2./log(a)) ./ ...
%       (gamma(n+1)*sqrt(2*pi*log(a)));
kern = exp(-y + (n-1).*log(y) - 0.5.*(log(y)-a).^2./log(a) - ...
       (gammaln(n+1)+log(sqrt(2*pi*log(a)))));
pdf = simps(kern) * dy;

return


Contact us