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

neyman_pdf(n, m1, m2)
% neyman_pdf.m - evaluates a Neyman Type A Probability Density.
%   See "Quantitative Spatial Analysis", R. Reich & R. Davis, CSU, 2000, web.
%
%  Created by Jim Huntley,  4/8/05
%

function [pdf] = neyman_pdf(n, m1, m2)

%persistent P logm2 P0 coef
persistent P

%if(isempty(logm2))
    logm2 = log(m2);
    P0 = exp(-m1*(1-exp(-m2)));
    coef = m1 * m2 * exp(-m2);
%end

pdf = P0;
if(n > 0)
    P(1) = pdf;
    sum1 = 0;
    for jt = 1:n
       %sum1 =  sum1 +  m2^(jt-1) * P(n-jt+1) / factorial(jt-1);
       sum1 =  sum1 +  exp((jt-1)*logm2 + log(P(n-jt+1)) - gammaln(jt));
    end
    pdf =  coef * sum1 / n;
    P(n+1) = pdf;
end

return

Contact us