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

extstir2l_pdf(n, k, theta, tau)
% extstir2l_pdf.m - evaluates an Extended Stiling 2L Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.323, 2005. 
%
%  Created by Jim Huntley,  01/09/07
%

function [pdf] = extstir2l_pdf(n, k, theta, tau)

%persistent coef logtheta

% Initializations.
%if(isempty(coef))
    %coef = factorial(k) * exp(-theta*tau) /(exp(theta) - 1)^k;
    coef = gammaln(k+1) + (-theta*tau) - k*log(exp(theta) - 1);
    logtheta = log(theta);
%end

% Evaluate PDF.

%pdf = carlitz2(n,k,tau) * theta^n * coef / factorial(n);
pdf = exp(log(carlitz2(n,k,tau)) + n*logtheta + coef - gammaln(n+1));

return

Contact us