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

wrgp_pdf(n, a, s, alpha)
% wrgp_pdf.m - evaluates a Weighted Restricted 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: Parameters have an unusual constraint: 
%           0 < (1+alpha/(n+1))*(1+alpha/(1+alpha))^(n+s)*a*exp(-a*alpha) < 1 for large n
%           implying that "a" is small (< 1) and alpha is smaller (<< 1).
%           See "check".
%
%   Created by Jim Huntley,  10/29/09
%

function [pdf] = wrgp_pdf(n, a, s, alpha)

%persistent lR

%if(isempty(lR))
    iimax = 50;
    sumi = 0;
    for ii = 1:iimax
        i = ii - 1;
        sumi = sumi + exp((i+s)*log(1+i*alpha) + i*log(a) - i*a*alpha - gammaln(i+1));
    end
    lR = log(sumi);
%end

pdf = exp((n+s)*log(1+n*alpha) + n*log(a) - n*a*alpha - lR - gammaln(n+1));

return

Contact us