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?
numpyis 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 hownumpyworks. – Sycorax Feb 06 '20 at 16:26[[1,0.5],[0.5,1]]right? I think this is the last hurdle for me to fully understand what you meant. – GENIVI-LEARNER Feb 06 '20 at 17:01numpyimplementation is playing fast-and-loose with the definition of "random vector" and inferring that, loosely, you want 3 values that are perfectly correlated. This is well-defined in 1 dimension, so it's just replicating the single value 3 times. – Sycorax Feb 06 '20 at 17:21