Open In App

Python | Numpy np.multinomial() method

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

# using np.multinomial() method
gfg = np.random.multinomial(8, [0.1, 0.22, 0.333, 0.4444], 2)

print(gfg)
Output :
[[1 4 2 1] [0 0 3 5]]
Example #2 : Python3 1=1
# import numpy
import numpy as np

# using np.multinomial() method
gfg = np.random.multinomial(12, [0.1, 0.12, 0.123, 0.1234, 0.12345], 3)

print(gfg)
Output :
[[2 0 1 1 8] [0 1 1 1 9] [1 1 1 0 9]]

Next Article

Similar Reads