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

match_pdf(n, nn)
% match_pdf.m - evaluates a Matching Probability Density.
%   See "Generating Non-Uniform Random Variates", Chap. 10, L. Devroye
%
%  Created by Jim Huntley,  9/6/06
%

function [pdf] = match_pdf(n, nn)

sum1 = 0;
for jn = 1:nn-n+1
	sum1 = sum1 + (-1)^(jn-1) / factorial(jn-1);    
end

pdf = exp(log(sum1+eps) - gammaln(n+1));

return

Contact us