Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python | Numpy np.multinomial() method

  • Last Updated : 13 Oct, 2019

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.




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




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

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!