File Exchange

image thumbnail

Sample a truncated multivariate normal distribution

version 1.0.0 (1.56 KB) by Yavor Kamer
Generates samples from a MVN within a lower and upper bound.

3 Downloads

Updated 24 Oct 2018

View License

There exist many implementations on FEX solving the same problem, I wasn't very confident in using them as they sometimes failed to converge (using fsolve etc) or would generate warnings complaining about the covariance matrix being close to singular.
This is a simple brute-force method that records the accepted samples, adjusts the trial size and repeats until it has reached the target sample number.

Cite As

Yavor Kamer (2020). Sample a truncated multivariate normal distribution (https://www.mathworks.com/matlabcentral/fileexchange/69201-sample-a-truncated-multivariate-normal-distribution), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Ahmad Fakih

Thanks, is this code confirmed to work properly?

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux