Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

trunpois_pdf(n, m, nn, lambda)
% trunpois_pdf.m - evaluates a Trucated Poisson Probability Density.
%   See "The Mathematical Gazette", 1983, p. 216.  
%
%  Created by Jim Huntley,  03/25/11
%

function [pdf] = trunpois_pdf(n, m, nn, lambda)

%persistent coef llambda

%if(isempty(coef))
    llambda = log(lambda);
    sumi = 0;
    for ji = m:nn
        sumi = sumi + exp(ji*llambda - gammaln(ji+1));
    end
    coef = 1 / sumi;
%end

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

return

Contact us