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

expgam_cdf(x, a, mu, alpha, bet, lambda)
% expgam_cdf.m - evaluates Eponential Gamma Mix Cumulative Distribution.
%   See "On the Linear Combination of Exponential and Gamma Random Variables",
%   S. Nadarajah and S. Kotz, Entropy, vol.7, no.2, 2005, p.161.
%
%  Created by Jim Huntley,  01/03/08
%

function [cdf] = expgam_cdf(x, a, mu, alpha, bet, lambda)

%persistent mdb gama mal mala lb ldal albet malmlba arg 

%if(isempty(mdb))
    mdb = mu / bet;
    gama = gammaln(a);
    mal = mu * alpha;
    mala = mal^a;
    lb = lambda * bet;
    ldal = lambda / alpha;
    albet = alpha * bet;
    malmlba = (mal - lb)^a;
    arg = (mal-lb) / albet;
%end

if(bet >= 0)
    %cdf = (gammainc(mdb*x,a) - mala * exp(-ldal*x) * gammainc(arg*x,a) / malmlba) / gama;
    cdf = exp(log(eps + gammainc(mdb*x,a) - mala * exp(-ldal*x) * gammainc(arg*x,a) / malmlba) - gama);
elseif(bet < 0)
    cdf = 1 - mala * exp(-ldal*x) / malmlba;
end

return

Contact us