0

I want to generate 36 pairs of numbers on a two-dimensional normal distribution with the covariance matrix C = [1, 0.8; 0.8, 1], the expected value vector is the zero vector (μ=0= (0,0)).

From what I've learnt so far, a matrix A with covariance matrix C could be calculated like this

C = [1, 0.8; 0.8, 1];

A = sqrtm(C);

But how do I generate the 36 pairs of numbers in Matlab?

Silverlik
  • 19
  • 4
  • 2
    You can use [`mvnrnd`](https://www.mathworks.com/help/stats/mvnrnd.html). Or if you want to do it manually (generate iid variables and multiply by a matrix to introduce the desired correlation) I think you need the Cholesky decomposition: `B = chol(C)`, not `sqrtm` – Luis Mendo Oct 20 '21 at 14:19
  • 1
    @LuisMendo Thanks, this helped! – Silverlik Oct 20 '21 at 14:47

0 Answers0