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

poismix_pdf(n, lambda, alpha, m, nn)
% test_poismix.m - tests a Poisson Mixture Probability Density.
%   See "A Unified Approach to Some Mixed Poisson Distributions", 
%   M.E. Ghitany and S.A. Al-Awadhi, Tamsui Oxford J. of Math. Sciences, p.147, 2001.
%
%  Created by Jim Huntley,  04/15/09
%

function [pdf] = poismix_pdf(n, lambda, alpha, m, nn)

%persistent gamm z1 z2

%if(isempty(gamm))
    gamm = gammaln(m);
    z1 = nn * (alpha+1);
    z2 = nn * alpha;
%end

for jn = 1:size(n,2)
    %pdf = z1^(-n-m) * nn^n * gamma(n+m) * KummerU([n+m,lambda],[],-1/z1) ...
    %     / (z2^(-m) * gamm * gamma(n+1) * KummerU([m,lambda],[],-1/z2));
    a = n(jn) + m;
    b = n(jn) + m + 1 - lambda;
    z = nn * (alpha+1);
    Unum = KummerU(a, b, z);
    a = m;
    b = m + 1 - lambda;
    z = nn * alpha;
    Uden = KummerU(a, b, z);
    %pdf(jn) = gamma(n(jn)+m) * nn^(n(jn)) * real(Unum) / (gamm * gamma(n(jn)+1) * real(Uden));
    pdf(jn) = exp(gammaln(n(jn)+m) + n(jn)*log(nn) + log(real(Unum)) - (gamm + gammaln(n(jn)+1) + log(real(Uden))));
end

return

Contact us