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

transbet2_cdf(x,a,p,q)
% transbet2_cdf.m - compute Transformed Beta Cumulative Distribution Function.
%   See "Modern Reserving Techniques for the Insurance Business", 
%   T. Hoedemakers, U. Leuven, 2005.
%
%  Created by:  Jim Huntley,  07/19/06.
%

function [cdf] = transbet2_cdf(x,a,p,q)

%Fast numerical estimation of CDF. SET SOLUTION TYPE = "3" !!!
tol = 1e-8;
trace = [];
warning off MATLAB:quad:MinStepSize;
%
minx = min(x);
%
% Integrate PDF to get CDF.
warning off MATLAB:quad:MinStepSize
sz = size(x,2);
for jz = 1:sz
    cdf(jz) = quad(@transbet2_pdf,minx,x(jz),tol,trace,a,p,q);
end

% Slow analytical solution for CDF. SET SOLUTION TYPE = "4" !!!
%coef = abs(a)/beta(p,q);
%coef2 = coef / (a*q);
%pm1 = p - 1;
%mpmq = -p - q;
%x2a = x.^a;
%x2apm1 = x.^(a*pm1);
%cdf = -coef2 .* (x2apm1 .* (1+x2a).^mpmq + ...
%      x.^(a*p) .* (1+x2a).^mpmq - x2apm1 .* ...
%      hypergeom([p+q, -1+p],p,-x2a));

return



Contact us