Some Julia code to sample from a truncated normal distribution. The code implementes the method described in
Nicolas Chopin (2011). Fast simulation of truncated Gaussian distributions. Statistics and Computing 21(2), 275-288.
and
Vincent Mazet (2012). Simulation d'une distribution gaussienne tronquée sur un intervalle fini. Technical Report, Université de Strasbourg/CNRS.
For code in other languages, see Vincent Mazet's page.