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

genlaplsum_pdf(x, mu, lambda, theta, phi)
% genlaplsum_pdf.m - evaluates a Generalized Laplace Sum Probability Density.
%   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 [pdf] = genlaplsum_pdf(x, mu, lambda, theta, phi)

for jx = 1:size(x,2)
    if(phi < x(jx)-theta)
        pdf(jx) = (lambda.*mu.*(lambda.*exp(mu.*(phi + theta - x(jx))) - mu.*exp(lambda.*(phi + theta - x(jx))))) ./ ...
                   (2.*(lambda^2 - mu^2));
    elseif(phi >= x(jx)-theta)
        pdf(jx) = (lambda.*mu.*(lambda./exp(mu.*(phi + theta - x(jx))) - mu./exp(lambda.*(phi + theta - x(jx))))) ./ ...
                    (2.*(lambda^2 - mu^2));
    end
end

return

Contact us