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

lagkatz1_pdf(n, bet, b)
% lagkatz1_pdf.m - evaluates a Lagrangian Katz 1 Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, 331. 
%
%  Created by Jim Huntley,  6/26/07
%

function [pdf] = lagkatz1_pdf(n, bet, b)

%persistent logbet logomb

%if(isempty(logbet))
    logbet = log(bet);
    logomb = log(1-bet);
%end

%pdf = binomial_coef(b*n/bet+n-2,n-1) * bet^(n-1) *(1-bet)^(b*n/bet) / n;
pdf = exp(log(binomial_coef(b*n/bet+n-2,n-1)+eps) + (n-1)*logbet + ...
           (b*n/bet)*logomb - log(n));       % Katz 1; Bazargan-Lari (3) = UDD p.331 with a correction.
    
return

Contact us