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

genlaplsum_cdf(x, mu, lambda, theta, phi)
% genlaplsum_cdf.m - evaluates a Generalized Laplace Sum Cumulative Distribution.
%   See "The Linear Combination, Product and Ratio of Laplace Random Variables", 
%   Statistics, Vol.41, No.6, p.535, December, 2007,
%   http://pdfserve.informaworld.com/566451__787690033.pdf.
%
%  Created by Jim Huntley,  01/29/10
%

function [cdf] = genlaplsum_cdf(x, mu, lambda, theta, phi)

for jx = 1:size(x,2)
    p = lambda .* (x(jx)-theta-phi);
    r = mu .* (theta+phi-x(jx));
    if(phi < x(jx)-theta)
        expr = exp(r);
        expmp = exp(-p);
        cdf(jx) = 1 - 0.5.*expr - 0.25.*mu.*expmp./(mu+lambda) - 0.25.*mu.*(expr-expmp)/(lambda-mu) + ...
                    0.25.*mu.*expr./(mu+lambda);
    elseif(phi >= x(jx)-theta)
        expmr = exp(-r);
        expp = exp(p);
        cdf(jx) = 0.5.*expmr - 0.25.*mu.*expmr./(mu+lambda) + 0.25.*mu.*(expp-expmr)/(mu-lambda) + ...
                    0.25.*mu.*expp./(mu+lambda);
    end
end

return

Contact us