So I want to sample from multivariate normal distribution and have this code where mean is 0 and I added covariance matrix with all entries to 1 implying all random variables are equally correlated.
import numpy as np
X = [0,1,2]
samples = np.random.multivariate_normal([0,0,0], [[1,1,1],[1,1,1],[1,1,1]])
print(samples)
>> samples [-0.89635305 -0.89635305 -0.89635305]
The question is for computing the trinormal distribution the cholesky decomposition of the covariance matrix has to be done, but here the rank of the matrix is 1, so why the code works and doesnt throw error?
It only gives warning if the covariance matrix is following:
[[1,0,1],[0,1,0],[1,1,1]]
Any explanation for this?
numpy
is doing, but clearly it's smart enough to detect that $\Sigma$ is not full rank and use an alternative strategy. You can read the source to find out hownumpy
works. $\endgroup$ – Sycorax♦ Feb 6 '20 at 16:26