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

composition_pdf(n, N, K)
% composition_pdf.m - evaluates an Anderson Composition Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, & Kotz,
%   J. Wiley, p.438, 2005. 
%
%  Created by Jim Huntley,  12/05/06
%

function [pdf] = composition_pdf(n, N, K)

%persistent Km2 t1 
    
%if(isempty(Km2))
    Km2 = K-2;
    t1 = Km2 * gammaln(N+1);
%end

sum1 = 0;
coef = exp(-gammaln(n+1) - t1);
for jj = 1:N-n+1
    jjm1 = jj - 1;
    sum1 = sum1 + (-1)^jjm1 * exp(Km2*gammaln(N-n-jjm1+1) - gammaln(jj));
end
pdf = coef * sum1;

return


Contact us