Exponentially modified Gaussian (exGaussian) distribution describes the sum of independent normal and exponential random variables.
This distribution was proposed as a model for the shape of chromatographic peaks  and is also used in psychology, psychophysiology and neuroscience as a model of reaction times [2-4].
Let us consider reaction times as an example. Overall reaction time can be partitioned into two components [2, Chapter 4], :
- time taken to decide upon a response (“decision component”);
- time taken to perceive the stimulus and to physically perform the response (“transduction component”)
Transduction component can be modelled by normal distribution with a mean of mu and a standard deviation of sigma. Decision component can be modelled by exponential distribution with a mean of tau. Then the overall reaction time is modelled by exGaussian with parameters mu, sigma and tau.
This submission contains three functions dealing with exGaussian distribution:
- exgauss_rnd.m generates exGaussian random numbers;
- exgauss_pdf.m computes the probability density function (pdf) of the exGaussian distribution (for example, if after you have estimated parameters of exGaussian distribution for your data using exgauss_fit, you can use exgauss_pdf to plot histogram of your data along with theoretical distribution);
- exgauss_diff_pdf.m computes the pdf of the difference of two exGaussian-distributed random variables (for example, assume that in your study to participant respond to the same stimuli. If you know exGaussian distributions behind reaction times of the participants of a study, you can use exgauss_diff_pdf to compute distribution of lags in participants’ reaction times, see example below).
Fitting exGaussian distribution (estimating parameters of exGaussian distribution underlying provided data) was described in , corresponding functions can be found at ;
EXAMPLE of use:
m1 = 3; std1 = 1.0; tau1 = 1; %parameters of reaction time for Participant 1
m2 = 2; std2 = 0.5; tau2 = 2; %parameters of reaction time for Participant 2
% generate distributions of reaction times (rt)
x = 0:0.001:9;
rt1 = exgauss_pdf(x, m1, std1, tau1);
rt2 = exgauss_pdf(x, m2, std2, tau2);
% generate distributions of reaction time difference (time gap between responses of Participants 1 and 2)
dltX = -7:0.001:6;
dRT = exgauss_diff_pdf(dltX, m1,std1,tau1,m2,std2,tau2);
LineWidth = 2;
subplot(2,1,1) % plot rt distribution
plot (x, rt1, 'b-', 'linewidth', LineWidth);
plot (x, rt2, 'r-', 'linewidth', LineWidth);
axis( [0.4, max(x), 0, 1.05*max(rt1)] );
subplot(2,1,2) % plot rt-difference distribution
plot (dltX, dRT, 'm-', 'linewidth', LineWidth);
axis( [min(dltX), max(dltX), 0, 1.05*max(dRT)] );
 Grushka E. (1972). Characterization of Exponentially Modified Gaussian Peaks in Chromatography. Analytical Chemistry. 44 (11): 1733–1738.
 Luce R.D. (1986). Response Times: Their Role in Inferring Elementary Mental Organization. Oxford University Press.
 Ratcliff R. (1993). Methods for Dealing with Reaction Time Outliers. Psychological Bulletin 114 (3): 510-532
 Dawson, M.R. (1988). Fitting the ex-Gaussian equation to reaction time distributions. Behavior Research Methods, Instruments, & Computers, 20(1): 54-57.
 Lacouture Y, Cousineau D. How to use MATLAB to fit the ex-Gaussian and other probability functions to a distribution of response times. Tutorials in Quantitative Methods for Psychology. 2008;4(1):35-45.
 https://github.com/ElsevierSoftwareX/SOFTX-D-16-00127. Accessed: 02.11.2018
Unakafov A.M. (2019). Exponentially modified Gaussian (ex-Gaussian) distributions (https://www.mathworks.com/matlabcentral/fileexchange/66575), MATLAB Central File Exchange. Retrieved February 21, 2019.
Dear Tobias, thank you very much for your remark. This was a misprint, which is now corrected
Where can I find the 'digit' function used in exgauss_pdf ? I can't run the program without it, and I can't seem to find it online with such a generic name
The risk of problems for small tau has been mitigated. Yet, tau < 0.1 are undesirable, in this case a change of units is recommended
Dear Tobias, thank you very much for your remark. It seems that my implementation gets unstable for small tau (<0.01). I will update the function in the next days.
Could be that the pdf I used below is wrong, I´ll look into it.
The pdf seems wrong, it produces strange results for small tau.
I use a different pdf here: https://www.mathworks.com/matlabcentral/fileexchange/70225-exgfit-fit-exgaussian-distribution-to-data
ncdf = @(x) 0.5*(1+erf(x/sqrt(2)));
exgausspdf = @(x,mu,tau,sigma) (1/tau).*exp((mu/tau)+(sigma^2/(2*tau^2))-(x/tau)).*ncdf( (x-mu-(sigma^2/tau))./sigma);
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!