Open In App

Python | Numpy np.multivariate_normal() method

Last Updated : 13 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
With the help of np.multivariate_normal() method, we can get the array of multivariate normal values by using np.multivariate_normal() method.
Syntax : np.multivariate_normal(mean, matrix, size) Return : Return the array of multivariate normal values.
Example #1 : In this example we can see that by using np.multivariate_normal() method, we are able to get the array of multivariate normal values by using this method. Python3 1=1
# import numpy
import numpy as np

mean = [1, 2]
matrix = [[5, 0], [0, 5]]
# using np.multinomial() method
gfg = np.random.multivariate_normal(mean, matrix, 10)

print(gfg)
Output :
[[ 6.24847794 6.57894103] [ 1.24114594 3.22013831] [ 3.0660329 2.1442572 ] [ 0.3239289 2.79949784] [-1.42964186 1.11846394] [-0.08521476 0.74518872] [ 1.42307847 3.27995017] [ 3.08412374 0.45869097] [ 2.2158498 2.97014443] [ 1.77583875 0.57446964]]
Example #2 : Python3 1=1
# import numpy
import numpy as np

mean = [0, 0, 0]
matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
# using np.multinomial() method
gfg = np.random.multivariate_normal(mean, matrix, 5)

print(gfg)
Output :
[[-2.21792571 -1.04526811 -0.4586839 ] [ 0.15760965 0.83934119 -0.52943583] [-0.9978205 0.79594411 -0.00937 ] [-0.16882821 0.1727549 0.14002367] [-1.34406079 1.03498375 0.17620708]]

Next Article

Similar Reads