Python | Numpy np.multinomial() method
Last Updated :
13 Oct, 2019
Improve
With the help of
Python3 1=1
Output :
Python3 1=1
Output :
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.
# 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)
[[1 4 2 1] [0 0 3 5]]Example #2 :
# 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)
[[2 0 1 1 8] [0 1 1 1 9] [1 1 1 0 9]]