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

rectnegbin_pdf(n, nn, p, k)
% rectnegbin_pdf.m - evaluates a Rectangular Negative Binomial Probability Density.
%   See "Lagrangian Probability Distributions", P.C. Consul & F. Famoye,
%   Birkhauser, 2006, Table 2.3.
%
%   Will not normalize properly for k*p >~ 0.4 -> 0.7 OR p >~ k!!!
%
%  Created by Jim Huntley,  11/18/08
%

function [pdf] = rectnegbin_pdf(n, nn, p, k)

q = 1 - p;

pdf = 1 / nn;
if(n > 0)
    sumr = 0;
    a = min(n-1,nn-2);
    for jr = 1:a+1
        r = jr - 1;
        sumr = sumr + (r+1) * binomial_coef(k*n+n-r-2,n-r-1) * p^(n-r-1);
    end
    pdf = q^(k*n) * sumr / (nn*n); 
end

return

Contact us