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

asyncount_pdf(n, k, lambdat)
% asyncount_pdf.m - evaluates an Asynchronous Counting Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.246, 2005. 
%
%  Created by Jim Huntley,  11/16/06
%

function [pdf] = asyncount_pdf(n, k, lambdat)

sum = 0;
if(n == 0)
    for jn = 1:k
        jndx = jn-1;
        %sum = sum + (1 - jndx/k) * (lambdat)^jndx / factorial(jndx);
        sum = sum + exp(log((1 - jndx/k) * (lambdat)^jndx) - gammaln(jndx+1));
    end
elseif(n > 0)
    for jn = 1:2*k-1
        jndx = jn-k;
        %sum = sum + (1 - abs(jndx)/k) * (lambdat)^(n*k+jndx) / factorial(n*k+jndx);
        sum = sum + exp(log((1 - abs(jndx)/k) * (lambdat)^(n*k+jndx)) - gammaln(n*k+jndx+1));
    end
end

pdf = sum * exp(-lambdat);

return


Contact us