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

binomdiff_pdf(n, N1, p1, N2, p2)
% binomdiff_pdf.m - evaluates a Binomial Difference Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp, and Kotz,
%   J. Wiley, p.142, 2005. 
%
%  Created by Jim Huntley,  11/21/06
%

function [pdf] = binomdiff_pdf(n, N1, p1, N2, p2)

% Initializations.
sum1 = 0;
jmin = max(0,n)+1;
jmax = min(N1,N2+n)+1;

for jn = jmin:jmax
    sum1 = sum1 + binomial_coef(N1,jn-1) * binomial_coef(N2,jn-n-1) * ...
                p1^(jn-1) * (1-p1)^(N1-jn+1) * p2^(jn-n-1) * (1-p2)^(N2+n-jn+1);
end
pdf = sum1;

return


Contact us