Using the numpy function numpy.random.multivariate_normal(), if I give the mean and covariance, I am able to draw random samples from a multivariate Gaussian.
As an example,
import numpy as np
mean = np.zeros(1000) # a zero array shaped (1000,)
covariance = np.random.rand(1000, 1000)
# a matrix of random values shaped (1000,1000)
draw = np.random.multivariate_normal(mean, covariance)
# this outputs one "draw" of a multivariate norm, shaped (1000,)
The above function outputs one "draw" from a multivariate Gaussian, shaped (1000,) (as the covariance matrix is shaped 1000,1000)).
I would like 200 draws. How does one do this? I would create a list comprehension, but I don't see how to create the iteration.
EDIT: Is there a difference between
draw_A = np.random.rand(1000, 1000, 200)
and
draw_B = [np.random.multivariate_normal(mean, covariance) for i in range(200)]
?
Yes, draw_B is a list, but are they both 200 independent draws shaped 1000,1000)?