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

appell(a, b1, b2, c, x1, x2)
% appell.m - Appell's Type 1 Hypergeometric Function by direct integration.
%   See "http://mathworld.wolfram.com/HypergeometricFunction.html",
%   E.W. Weisstein, 06/28/2004.
%
%   Created by  J. Huntley,  10/30/06.
%

function [Ap] = appell(a, b1, b2, c, x1, x2)

% Initializations.
tol = 1e-5;
trace = [];
%warning off all;
gama = gamma(a);
gamc = gamma(c);
gamcma = gamma(c-a);
nt = 2000;
delt = 1 / (nt-1);
t = 0:delt:1;

% Evaluate Appell Hypergeometric Function of Type 1.
%k = t.^(a-1) .* (1-t).^(c-a-1) .* (1-t.*x1).^(-b1) .* (1-t.*x2).^(-b2);                    
%kint = trapz(k) / nt;
kint = quadl(@kfun,0,1,tol,trace,a,b1,b2,c,x1,x2);
Ap = gamc * kint / (gama * gamcma);

return
        
function [k] = kfun(t,a,b1,b2,c,x1,x2)

k = t.^(a-1) .* (1-t).^(c-a-1) .* (1-t.*x1).^(-b1) .* (1-t.*x2).^(-b2);
                  
return

Contact us