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

betabin_pdf(n, alpha, bet, nn)
% betabin_pdf.m - evaluates a Beta Binomial Probability Density.
%   See "Dataplot Reference Manual, BBNPDF", Aux-31, NIST, 3/24/97.
%
%  Created by Jim Huntley,  8/04/04
%

function [pdf] = betabin_pdf(n, alpha, bet, nn)

%persistent coef

%if(isempty(coef))
    coef = 1 / ((nn+1)*beta(alpha,bet));
%end

for jn = 1:size(n,2)
    pdf(jn) = coef * beta(nn-n(jn)+alpha,n(jn)+bet) / beta(nn-n(jn)+1,n(jn)+1);
end

return

Contact us