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

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

function [pdf] = extstir2w_pdf(n, k, m, tau)

%persistent coef logmptau

% Initializations.
%if(isempty(coef))
    %coef = factorial(m) / factorial(m-k);
    coef = gammaln(m+1) - gammaln(m-k+1);
    logmptau = log(m+tau);
%end

% Evaluate PDF.

%pdf = carlitz2(n-1,k-1,tau) * coef / (m+tau)^n;
pdf = exp(log(carlitz2(n-1,k-1,tau)) + coef - n*logmptau);

return

Contact us