Python | Numpy np.multinomial() method

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

[[1 4 2 1]
[0 0 3 5]]



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

[[2 0 1 1 8]
[0 1 1 1 9]
[1 1 1 0 9]]

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.