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

dtrpois_pdf(n, theta, r1, r2)
% dtrpois_pdf.m - evaluates a Doubly Trncated Poisson Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.193, 2005. 
%
%  Created by Jim Huntley,  01/03/07
%

function [pdf] = dtrpois_pdf(n, theta, r1, r2)

%persistent coef ltheta

%if(isempty(coef))
    sum1 = 0;
    for jj = r1:r2
        sum1 = sum1 + theta^jj / gamma(jj+1);
    end
    coef = -log(sum1);
    ltheta = log(theta);
%end

pdf = exp(coef + n*ltheta - gammaln(n+1));

return


Contact us