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

simpbin_pdf(n, nn, mu, sigma)
% simpbin_pdf.m - evaluates a Simplex Binomial Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, p.491.
%
%   Note: distribution is derived from 4-parameter Simplex with 
%         alpha1 = alpha2 = -0.5.
%
%  Created by Jim Huntley,  10/02/07
%

function [pdf] = simpbin_pdf(n, nn, mu, sigma)

%persistent dp p t coef lambda

%if(isempty(coef))
    np = 1000;
    dp = 1 / (np-1);
    p = 1e-6:dp:1-1e-6;
    t = 0.5 .* (p-mu).^2 ./ (mu^2 .* (1-mu)^2 .* p .* (1-p));
    coef = 1 / (sqrt(2*pi*sigma^2));
    lambda = 1 / sigma^2;
%end

kern = p.^(n-1.5) .* (1-p).^(nn-n-1.5) .* exp(-lambda.*t);
pdf = coef * binomial(nn,n) * trapz(kern) * dp;
    
return

Contact us