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

nfctrnbin_pdf(n, k, theta, nn)
% nfctrnbin_pdf.m - evaluates an n-fold Convolution of Truncated negative Binomial
%                   Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, & Kotz,
%   J. Wiley, 2005, p.235.
%
%  Created by Jim Huntley,  7/26/07
%

function [pdf] = nfctrnbin_pdf(n, k, theta, nn)

%persistent coef

%if(isempty(coef))
    coef = ((1-theta)^(-k) - 1)^(-nn);
%end

sum1 = 0;
for ji = 1:nn
    sum1 = sum1 + (-1)^(nn-ji) * binomial_coef(nn,ji) * binomial_coef(n+k*ji-1,n) * theta^n;
end
pdf = coef * sum1;

return

Contact us