Friday, October 24, 2025
HomeLanguagesnumpy.random.get_state() in Python

numpy.random.get_state() in Python

With the help of numpy.random.get_state() method, we can get the internal state of a generator and return the tuple by using this method.

Syntax : numpy.random.get_state()

Return : Return the tuple having {tuple(str, ndarray of 624 units, int, int, float), dict}

Example #1 :

In this example we can see that by using numpy.random.get_state() method, we are able to get the tuple having internal state of a generator and return the tuple by using this method.

Python3




# import numpy and get_state
import numpy as np
 
# Using get_state() method
gfg = np.random.get_state()[0]
 
print(gfg)


Output :

MT19937

Example #2 :

Python3




# import numpy and get_state
import numpy as np
import matplotlib.pyplot as plt
 
# Using get_state() method
gfg = np.random.get_state()[1]
 
count, bins, ignored = plt.hist(gfg, 24, density = True)
plt.show()


Output :

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS