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

borelherm_pdf(n, m, lambda, m1, lambda1)
% borelherm_pdf.m - evaluates a Borel Hermite Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.400, 2005. 
%
%  Created by Jim Huntley,  11/29/06
%

function [pdf] = borelherm_pdf(n, m, lambda, m1, lambda1)

%persistent ll ll1 

%if(isempty(ll))
    ll = log(lambda);
    ll1 = log(lambda1);
%end

% Initializations.
sum1 = 0;
jlim = fix(n/2)+1;

% Calculate PDF.
for jn = 1:jlim
    %sum1 = sum1 + (m1+jn-1)^(jn-2)*lambda1^(jn-1)*exp(-lambda1*(m1+jn-1))*(m+n-2*jn+2)^(n-2*jn+1)* ...
    %      lambda^(n-2*jn+2)*exp(-lambda*(m+n-2*jn+2))/(factorial(jn-1)*factorial(n-2*jn+2));
    sum1 = sum1 + exp((jn-2)*log(m1+jn-1) + (jn-1)*ll1 + (-lambda1*(m1+jn-1)) + (n-2*jn+1)*log(m+n-2*jn+2) + ...
          (n-2*jn+2)*ll + (-lambda*(m+n-2*jn+2)) - (gammaln(jn) + gammaln(n-2*jn+3)));
end
pdf = sum1 * m1 * m;

return


Contact us