I want to draw a random vector from a multivariate normal distribution with given covariance matrix $Σ$.
I'm following this algorithm:
A widely used method for drawing a random vector $x$ from the $N$-dimensional multivariate normal distribution with mean vector $μ$ and covariance matrix $Σ$ works as follows:
- Find any real matrix $A$ such that $AA^T = Σ$. When $Σ$ is positive-definite (...)
But my covariance matrix is not positive-definite. It's positive-semidefinite. So, I can't use Cholesky decomposition. Further there is written:
An alternative is to use the matrix $A = UΛ^{\frac{1}{2}}$ obtained from a spectral decomposition $Σ = UΛU^T$ of $Σ$.
So, I have to use spectral decomposition? There is no easier way to draw such a random vector?
For such $Σ$:
0.666 -0.333
-0.333 0.666
Cholesky decompososition gives such $A$ (using this Online Matrix Calculator):
0.816 0.000
-0.408 0.707
Spectral decomposition, eigenvectors real values $U$:
0.707 0.707
-0.707 0.707
Eigenvalues $Λ$:
0.999 0.000
0.000 0.333
Fortunately square root of diagonal matrix is easy :) $Λ^{\frac{1}{2}}$:
0.999 0.000
0.000 0.577
$A=UΛ^{\frac{1}{2}}$:
0.707 0.407
-0.707 0.407
So, $A$ returned by spectral decomposition is different than this returned by Cholesky. Why? Is this correct?