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

occupy0_cdf(n,c,b)
% occupy0_cdf.m - compute Occupancy 0 (at least) Cumulative Distribution Function.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.255, 2005.                 
%
%  Created by:  Jim Huntley,  8/03/07.
%

function [cdf] = occupy0_cdf(n,c,b)

%persistent coef

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

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

return



Contact us