2

I am wishing to sample from a truncated multivariate normal distribution directly in Matlab.

I am aware I can simply use mvnrnd and check whether the returned value is within the domain of interest. However, this is a waste of resources when a large number of samples are needed.

Matlab has a built in function truncate reference that will truncate a given probability distribution object. Unfortunately, mvnpdf reference returns the value of the pdf at a given location, not the probability object see: pdf. Moreover, truncate only seems to support 1-dimensional problems.

Any ideas how to to sample directly from a truncated multivariate normal, aside from simply ignoring data outside the domain of interest? Or is this generally something I will have to live with?

Examples on the file exchange seem to implement some form of rejection sampling:

Truncated Normal Generator

Truncated Multivariate Normal Generator

Another Truncated Normal Generator

Clark
  • 133
  • 4

1 Answers1

0

Apparently, sampling from this distribution is not exactly trivial. But here are some pointers.

  • Truncated multivariate normal in SciPy? . There, the accepted answer uses Markov-chain Monte Carlo to sample based on the log-PDF of the truncated normal distribution. (Note that the answer uses Python, not MATLAB.)
  • https://hal.archives-ouvertes.fr/hal-01063978/document . This is an algorithm that samples from this distribution. Although this also uses rejection sampling, it may be more efficient if the domain of interest is far from the distribution's mode. It only works if the domain of interest is convex.
Peter O.
  • 32,158
  • 14
  • 82
  • 96