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

nandi_pdf(n, a, s, z)
% nandi_pdf.m - evaluates a Nandi (Generalized Poisson) Probability Density.
%   See "Some Aspects of a Sub-Class of Modified Power Series Distributions",
%   S. Chakraborty, Dibrugargh U., http://interstat.statjournals.net/YEAR/2006/articles/0604001.pdf 
%
%   NOTE:  In order to run in a reasonable time, keep |z| ~< 0.9 !!!
%
%  Created by Jim Huntley,  01/09/08
%

function [pdf] = nandi_pdf(n, a, s, z)

%persistent lsumi 

%if(isempty(lsumi))
    imax = fix(30/(1-z)^2);                      % heuristic
    sumi = 0;
    for ii = 1:imax
        i = ii - 1;
        sumi = sumi + exp((i+s)*log(a+i*z) - i*z - gammaln(i+1));
    end
    lsumi = log(sumi);
%end

pdf = exp((n+s)*log(a+n*z) - n*z - lsumi - gammaln(n+1));

return


Contact us