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

steyn2p_pdf(n, c, theta)
% steyn2p_pdf.m - evaluates a 2-parameter Steyn Logarithmic Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.522, 2005.  Note typo.
%
%  Created by Jim Huntley,  10/08/06
%

function [pdf] = steyn2p_pdf(n, c, theta)

%persistent coef logc

%if(isempty(coef))
    coef = 1 / log(1 - theta - c*theta^2);
    logc = log(c);
%end
    
sumi = 1/n;
nlim = fix(n/2);
for i = 1:nlim
    sumi = sumi + exp(i*logc + gammaln(n-i) - (gammaln(n-2*i+1) + gammaln(i+1)));
end
pdf = coef * -theta^n * sumi;  

return


Contact us