Exponentially modified Gaussian distribution

Hello,

I was recently asked about how to simulate an EMG (Exponentially modified Gaussian) random variable, which is the sum of a Gaussian (mean \mu, variance \sigma^2) and an Exponential (rate \lambda) random variables. This variable has the following PDF (probability density function):

f(x)=\frac{\lambda}{2}\exp\left(\frac{\lambda}{2}(2\mu+\lambda\sigma^2-2x)\right)\operatorname{erfc}\left(\frac{\mu+\lambda\sigma^2-x}{\sigma\sqrt{2}}\right),

where \operatorname{erfc}(x)=1-\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}}\displaystyle\int_x^\infty \exp(-t^2)\,dt.

The actual expression of the PDF is useful e.g. when you want to fit an empirical distribution, which allows to estimate \mu,\sigma and \lambda, but when you have these estimates, it is straightforward to simulate this random variable in Scilab thanks to the swiss-knife grand (grand - Random numbers). For example, let us do this for \mu=-3, \sigma=1, \lambda=1/4:


μ = 0;
σ = 10;
λ = 1/60;
N = 100000;

X = grand(N,1,"nor",μ,σ);
Y = grand(N,1,"exp",1/λ);
Z = X+Y;

clf
histplot(-50:10:400,Z)

x = -50:400;
lf = log(λ/2)+λ/2*(2*μ+λ*σ^2-2*x)+log(1-erf((μ+λ*σ^2-x)/(σ*sqrt(2))))
plot(x,exp(lf),"r","thickness",2)

emg

The empirical distribution (using 100000 samples) fits well the theoretical PDF (in red).

Another interesting information
Thank you

Hello,

I added the theoretical PDF on the plot.

S.

EMG= Exponentially modified Gaussian distributions have been useful to model flight altitude probabilites of soaring birds, attachment.
Heinz