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

binomtri_pdf(n, nn, theta)
% binomtri_pdf.m - evaluates a 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] = binomtri_pdf(n, nn, theta)

%persistent coef

%if(isempty(coef))
    coef = 1 / (1-theta);
%end

arg1 = n+2;
arg2 = nn-n+1;
arg3 = n+1;
arg4 = nn-n+2;
pdf = 2 * binomial_coef(nn,n) * (betainc(theta,arg1,arg2)*beta(arg1,arg2)/theta + ...
          coef*beta(arg3,arg4)* (1 - betainc(theta,arg3,arg4)));

return


Contact us