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

specocc_pdf(n, l, b, c)
% specocc_pdf.m - evaluates a Specified Occupancy Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, 442. 
%
%  Created by Jim Huntley,  7/16/07
%

function [pdf] = specocc_pdf(n, l, b, c)

%coef = factorial(l) / (factorial(n)*c^b);
coef = exp(gammaln(l+1) - (gammaln(n+1)+b*log(c)));
sum1 = 0;
for jn = n:l
    arg = jn - n;
    %sum1 = sum1 + (-1)^arg * (c-jn)^b / (factorial(l-jn)*factorial(arg));
    sum1 = sum1 + (-1)^arg * exp(b*log(c-jn) - (gammaln(l-jn+1)+gammaln(arg+1)));
end
pdf = coef * sum1;
    
return

Contact us