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

nbinomtri_pdf(n, theta, alpha)
% nbinomtri_pdf.m - evaluates a Negative Binomial Triangular Probability Density.
%   See "The Polygonal Distribution", D. Karlis and E. Xekalaki,
%   Inter Conf Math and Stat Modeling, June 28-30, 2006.
%
%  Created by Jim Huntley,  12/20/07
%

function [pdf] = nbinomtri_pdf(n, theta, alpha)

arg1 = alpha+2;
arg2 = n+1;
arg3 = alpha+1;
arg4 = n+2;
pdf = 2 * exp(gammaln(alpha+n)- gammaln(n+1) -gammln(alpha)) * (betainc(theta,arg1,arg2)*beta(arg1,arg2)/theta + ...
          beta(arg3,arg4)*(1 - betainc(theta,arg3,arg4))/(1-theta));

return


Contact us