Matlab: How to generate a 4x1 matrix of random variables, assuming a 4x4 correlation matrix?

I start with 4 time series designated A, B, C, D.

I create the following:

  • 4x1 matrix of funds.
  • 4x1 standard deviation matrix.
  • A 4x4 correlation matrix , taking 30 samples from each time series.

What is the Matlab code to generate a 4x1 matrix of random variables while maintaining correlations between time series?

(reason: this is the first simulation stage in Monte Carlo).

+3
source share
2 answers

( m) ( C). , , C = R - m*m' ( , ).

, C, IID ( ):

w = randn(4,1)

( Q) :

v = Q*w + m

sqlt Matlab sqrt (C) SVD EIG.

[u,d] = eig(C)

Q = u*sqrt(d)*u'

v Q*Q' (= C), m

. wikipedia .

+4

Statistics, mvnrnd .

C, cov , nimrodm.

mvnrnd(m, C)

m - .

+2

All Articles