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

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

function [pdf] = leakurn_pdf(n, p, b, c)

%persistent coef

%if(isempty(coef))
    %coef = factorial(c) / (factorial(n)*c^b);
    coef = exp(gammaln(c+1) - (gammaln(n+1)+b*log(c)));
%end

sum1 = 0;
for ji = 1:c-n+1
    %sum1 = sum1 + (-1)^(ji-1) * (c-p*(n+ji-1))^b - (factorial(j-1)*factorial(c-n-ji+1));
    sum1 = sum1 + (-1)^(ji-1) * exp(b*log((c-p*(n+ji-1))) - (gammaln(ji)+gammaln(c-n-ji+2)));
end
pdf = coef * sum1;
    
return

Contact us