MATLAB implementation of the algorithm introduced in "Exact Hamiltonian Monte Carlo for Truncated Multivariate Gaussians" by Ari Pakman and Liam Paninski.
Paper available at http://arxiv.org/abs/1208.4118
The function brownian_bridge_demo reproduces one of the examples in the paper.
For an R package based on a faster C++ implementation, see: https://cran.r-project.org/web/packages/tmg/index.html