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

rtpois_pdf(n, theta, r2)
% rtpois_pdf.m - evaluates a Right Truncated Poisson Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, p.192. 
%
%  Created by Jim Huntley,  10/01/07
%

function [pdf] = rtpois_pdf(n, theta, r2)

%persistent coef ltheta

%if(isempty(coef))
    ltheta = log(theta);
    sumj = 0;
    for jj = 1:r2+1
        j = jj-1;
        sumj = sumj + exp(j*ltheta - gammaln(jj));
    end
    coef = 1 / sumj;
%end

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

Contact us