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

poisdiff_pdf(n, lambda1, lambda2)
% poisdiff_pdf.m - evaluates a Poisson Difference Probability Density.
%   See "Generating NonUnifom Random Deviates", Chap. 9, L. Devroye.
%
%  Created by Jim Huntley,  04/14/09
%

function [pdf] = poisdiff_pdf(n, lambda1, lambda2)

%persistent coef lamrat trtlampr

%if(isempty(coef))
    lamrat = lambda1 / lambda2;
    trtlampr = 2 * sqrt(lambda1*lambda2);
    coef = exp(-lambda1-lambda2);
%end

pdf = coef * lamrat^(0.5*n) * besseli(n,trtlampr); 

return

Contact us