Question #369
Submitted by Answiki
on 01/10/2021 at 12:31:48 PM UTC
In Python, how to create an array of n x m random integers?
Merged questions
Answer
Submitted by Answiki
on 01/10/2021 at 12:38:01 PM UTC
The NumPy function numpy.random.randint(low, high=None, size=None, dtype='l') is devoted to return random numbers. By setting the size option, the function can return a numpy.ndarray of random integer :
>>> import numpy as np
>>> np.random.randint(low = 0, high = 10, size=(3,2))
array([[8, 7],
[8, 2],
[6, 2]])
Question by Answiki 01/10/2021 at 12:38:25 PM
In Python, how to create an NumPy array of random integers?
Answer by Answiki on 01/10/2021 at 12:38:01 PM
The NumPy function numpy.random.randint(low, high=None, size=None, dtype='l') is devoted to return random numbers. By setting the size option, the function can return a numpy.ndarray of random integer :
>>> import numpy as np
>>> np.random.randint(low = 0, high = 10, size=(3,2))
array([[8, 7],
[8, 2],
[6, 2]])
Question by Answiki 01/10/2021 at 12:31:48 PM
In Python, how to create an array of n x m random integers?
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13567 | alphons | https://en.ans.wiki/369/in-python-how-to-create-an-array-of-n-x-m-random-integers | 1 |
| 1 | 11851 | en | https://en.ans.wiki/369/in-python-how-to-create-an-array-of-n-x-m-random-integers | 4 |
Icons proudly provided by Friconix.