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

headmtail_pdf(n, nn)
% headmtail_pdf.m - evaluates a Heads-Minus-Tails Probability Density.
%   See "Heads-Minus-Tails Distribution", Wolfram,
%   "http://mathworld.wolfram.com/Heads-Minus-TailsDistribution.html".
%
%  Created by Jim Huntley,  01/04/08
%

function [pdf] = headmtail_pdf(n, nn)

pdf = 0;

if(mod(n,2) == 0)
    k = fix(n/2);
    if(n == 0)
        pdf = 0.5^(2*nn) * binomial_coef(2*nn,nn);
    elseif(n > 0)
        pdf = 2 * (0.5)^(2*nn) * binomial_coef(2*nn,nn+k);
    end
end

return


Contact us