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

singh_pdf(n, a, alpha)
% singh_pdf.m - evaluates a Singh Poisson Probability Density.
%   See "Word Length and Frequency Distributions in Different Text Genres", 
%  G. Antic et al., Graz University.
%
%  Created by Jim Huntley,  8/02/06
%

function [pdf] = singh_pdf(n, a, alpha)

%persistent loga logalph

%if(isempty(loga))
    loga = log(a);
    logalph = log(alpha);
%end

if(n == 1)
    pdf = 1 - alpha + alpha*exp(-a);
elseif(n > 1)
    %y = alpha * a^(n-1) * exp(-a) / factorial(n-1);
    pdf = exp(logalph + (n-1)*loga - a - gammaln(n));
end

return

Contact us