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

poispoly_pdf(n, theta, a)
% poispoly_pdf.m - evaluates a Poisson Polynomial Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, 2005, p.487.    
%
%  Created by Jim Huntley,  9/11/07
%

function [pdf] = poispoly_pdf(n, theta, a)

%persistent coef ltheta

%if(isempty(coef))
    C = 1 / ((1+a*theta)^2 + a^2*theta);
    %coef = C * exp(-theta);
    coef = log(C * exp(-theta));
    ltheta = log(theta);  
%end

%pdf = coef * theta^n * (1 + a*n)^2 / gamma(n+1);
pdf = exp(coef + n*ltheta + 2*log(1+a*n) - gammaln(n+1));

return

Contact us