Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

cnormlapl_cdf(x, sigma, theta, phi)
% cnormlapl_cdf.m - evaluates a Compount Normal Laplace Cumulative Distribution.
%   See "Continuous Univariate Distributions", Vol.2, Johnson, Kotz &
%   Balakrishnan, p.194, 1995.
%
%  Created by Jim Huntley,  04/02/09
%

function [cdf] = cnormlapl_cdf(x, sigma, theta, phi)

%persistent c1 coef sdp

%if(isempty(coef))
    c1 = 1 / sqrt(2*pi);
    coef = 0.5 * exp(sigma^2/(2*phi^2));
    sdp = sigma / phi;
%end

args = (x - theta) ./ sigma;
argp = (x - theta) ./ phi;
s1 = sdp - args;
s2 = sdp + args;
harg1 = -0.5 .* s1.^2;
harg2 = -0.5 .* s2.^2;
for jx = 1:size(x,2)
    h1(jx) = s1(jx) .* genHyper(0.5,1.5,harg1(jx));
    h2(jx) = s2(jx) .* genHyper(0.5,1.5,harg2(jx));
end
cdf = gaus_cdf(args,0,1) + coef.*sinh(argp) - c1.*coef.* ...
          (exp(argp).*h2 - exp(-argp).*h1);

return

Contact us