Python | The numpy np.multinomial () method



With the np.multinomial() method we can get an array of polynomial distribution using np.multinomial () .

Syntax: np.multinomial (n, nval, size)
Return: Return the array of multinomial distribution.

Example # 1:
In this example, we see that with np.multinomial () we we can get an array of polynomial distribution using this method.

# NumPy imports

import numpy as np

 
# using the 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 No. 2:

# NumPy import

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]]