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

geneuler_pdf(n, q, a, lambda)
% geneuler_pdf.m - evaluates a Generalized Euler Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, p.472, 2005. 
%
%  Created by Jim Huntley,  01/30/07
%

function [pdf] = geneuler_pdf(n, q, a, lambda)

% n == 0 term ('prod0')
prod0 = 1;
jlim = min(200,fix(1 / ((1-a) * (1-q)) + 1e-6));
jlim = max(jlim,30);
for jj = 1:jlim
    prod0 = prod0 * (1-lambda*q^(jj-1)) / (1-a*lambda*q^(jj-1));
end

% (a,q)_n term ('prod1') and (q,q)_n term ('prod2').
prod1 = 1;
prod2 = 1;
for jn = 1:n
    prod1 = prod1 * (1-a*q^(jn-1));
    prod2 = prod2 * (1-q^jn);
end

% Compute PDF.
pdf = prod0 * lambda^n * prod1 / prod2;

return


Contact us