# how to use rmvnrnd file to draw multivariate truncated normal distributions?

Asked by FMR on 11 Aug 2012
Latest activity Answered by the cyclist on 12 Aug 2012

Hello all,

could you please share an example of how to use the matlab function rmvnrnd?

I am trying to generate a three multivariate truncated normal with data

MU=[5,4,3]; Sigma = [1 .3 .3; .3 1.5 .4; .3 .4 2.5] N=1000;

A=[-10;10;20]; B=[500,600,1000];

However the limits on A and B looks that are not working, I think I did a wrong specification of them. Could you give me a example please?

what I want to do is to have the limits:

X1 belongs to [-10,500] X2 belongs to [10,600] X3 belongs to [20,1000]

## Products

No products are associated with this question.

Answer by the cyclist on 12 Aug 2012

Do you mean this function from the FEX?:

http://www.mathworks.com/matlabcentral/fileexchange/34402-truncated-multivariate-normal

If so, then according to the documentation of that function, A and B are not lower and upper limits. Rather, A*x <= B. So, for example,

```>> r = rmvnrnd(0,1,10000000,3,2);
```

will mean that all of the values of r are less than 2/3.