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

binchisq_pdf(nh, nn, c, sd2)
% binchisq_pdf.m - tests a Compound Binomial Chi-Square Probability Density.
%   See "The Compounding of the Binomial and Generalized Beta Distributions",   
%   T. Gerstenkorn, Prob. and Statistical Inference, p.87, 1982. 
%
%   NORMALIZATION PUTS A COMPLICATED UPPER LIMIT ON 'c'.
%
%  Created by Jim Huntley,  06/09/11
%

function [pdf] = binchisq_pdf(nh, nn, c, sd2)

for jn = 1:size(nh,2) 
    sumk = 0;
    n = nh(jn);
    gamsd2 = gamma(sd2);
    bcnndx = binomial_coef(nn,n);
    for jk = 1:nn-n
        k = jk - 1;
        sumk = sumk + binomial_coef(nn-n,k) * (-1)^k * (2*c)^(n+k) * ...
               gamma(sd2+n+k);
    end
    pdf(jn) = sumk * bcnndx / gamsd2;
end

return

Contact us