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

genlapldif_cdf(x, mu, lambda, theta, phi)
% genlapldif_cdf.m - evaluates a Generalized Laplace Difference 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] = genlapldif_cdf(x, mu, lambda, theta, phi)

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

return

Contact us