Draw random samples from a multivariate normal distribution.
The multivariate normal, multinormal or Gaussian distribution is a generalization of the onedimensional normal distribution to higher dimensions. Such a distribution is specified by its mean and covariance matrix. These parameters are analogous to the mean (average or “center”) and variance (standard deviation, or “width,” squared) of the onedimensional normal distribution.
Parameters :  mean : 1D array_like, of length N
cov : 2D array_like, of shape (N, N)
size : tuple of ints, optional


Returns :  out : ndarray

Notes
The mean is a coordinate in Ndimensional space, which represents the location where samples are most likely to be generated. This is analogous to the peak of the bell curve for the onedimensional or univariate normal distribution.
Covariance indicates the level to which two variables vary together. From the multivariate normal distribution, we draw Ndimensional samples, . The covariance matrix element is the covariance of and . The element is the variance of (i.e. its “spread”).
Instead of specifying the full covariance matrix, popular approximations include:
 Spherical covariance (cov is a multiple of the identity matrix)
 Diagonal covariance (cov has nonnegative elements, and only on the diagonal)
This geometrical property can be seen in two dimensions by plotting generated datapoints:
>>> mean = [0,0]
>>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or yaxis
>>> import matplotlib.pyplot as plt
>>> x,y = np.random.multivariate_normal(mean,cov,5000).T
>>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show()
Note that the covariance matrix must be nonnegative definite.
References
Papoulis, A., Probability, Random Variables, and Stochastic Processes, 3rd ed., New York: McGrawHill, 1991.
Duda, R. O., Hart, P. E., and Stork, D. G., Pattern Classification, 2nd ed., New York: Wiley, 2001.
Examples
>>> mean = (1,2)
>>> cov = [[1,0],[1,0]]
>>> x = np.random.multivariate_normal(mean,cov,(3,3))
>>> x.shape
(3, 3, 2)
The following is probably true, given that 0.6 is roughly twice the standard deviation:
>>> print list( (x[0,0,:]  mean) < 0.6 )
[True, True]