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

lcointoss_pdf(n, nn)
% lcointoss_pdf.m - evaluates a Leads in Coin Toss Probability Density.
%   See "Dataplot Reference Manual", LCTPDF, NIST.
%
%  Created by Jim Huntley,  12/10/07
%

function [pdf] = lcointoss_pdf(n, nn)

%persistent term

%if(isempty(term))
    term = 2 * nn * log(2);
%end

%    pdf = factorial(2*n) * factorial(2*nn-2*n) * 2^(-2*nn) / ...
%              (factorial(n) * factorial(nn-n))^2;
    pdf = exp(gammaln(2*n+1) + gammaln(2*nn-2*n+1) - term - ...
              2*(gammaln(n+1) + gammaln(nn-n+1)));         

return


Contact us