jeudi 21 janvier 2016

Draw multiple samples using numpy.random.multivariate_normal(mean, cov[, size])

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,)).

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.




Aucun commentaire:

Enregistrer un commentaire