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

extherm_pdf(n, m, a1, am)
% extherm_pdf.m - evaluates an Extended Hermite Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.399, 2005. 
%
%  Created by Jim Huntley,  01/04/07
%

function [pdf] = extherm_pdf(n, m, a1, am)

%persistent logam loga1

%if(isempty(logam))
    logam = log(am);
    loga1 = log(a1);
%end

pdf = exp(-a1-am);
if(n > 0)
    sum1 = 0;
    for jj = 1:fix(n/m)+1
        jjm1 = jj-1;
        arg = n-m*jjm1;
        %sum1 = sum1 + am^jjm1 * a1^arg / (factorial(jjm1) * factorial(arg));
        sum1 = sum1 + exp(jjm1*logam + arg*loga1 - (gammaln(jj) + gammaln(arg+1)));
    end
    pdf = pdf * sum1;
end

return

Contact us