Simulation of truncated Gaussian Distribution

In 2005, we developped a first method to generate random variables distributed from a Gaussian distribution defined on a semi-finite interval [a,+∞[. This method was implemented in Scilab, Matlab and Java.

Following the article published in 2011 by Nicolas Chopin, we have developped a method to simulate a Gaussian distribution defined on a finite interval [a,b]. This method is still able to consider semi-finite interval by setting b = +∞. The principle is to divide the interval into regions with the same area where acceptation-reject algorithms with appropriate distributions are used.

Nicolas Chopin's method is coded in C, but only on a semi-finite interval [a,+∞[. We extend his method to a finite interval [a,b], following its recommandations. The method is implemented in Matlab and C++; it is faster than our former implementation and also allows to consider a finite interval. However, it is still not able to generate a random vector, contrary to the version of 2005.

The following table summarize the implementations and their characteristics, as well as similar implementations in other languages :

Code Author Year Size Language Dimensions Truncation
truncgauss N. Chopin 2011 462 kb C
semi-finite or finite
rpnorm V. Mazet 2005 2 kb Matlab, Scilab, Java 1 or greater semi-finite
rtnorm V. Mazet 2012 58 kb Matlab 1 semi-finite or finite
rtnorm G. Dollé, V. Mazet 2012 67 kb C++ 1 semi-finite or finite
rtnorm C. Lassner 2013 60 kb Python 1 semi-finite or finite
dtnorm Alan R. Rogers 2016 232 kb C 1 finite

Documents and codes