numpy.random.random_integers()
— one of the functions for random sampling in numpy. It returns an array of the specified shape and fills it with random integers from low (inclusive) to high (excluding), that is, in the range [low, high).
Syntax: numpy.random.random_integers (low, high = None, size = None)
Parameters:
low: [int] Lowest (signed) integer to be drawn from the distribution.But, it works as a highest integer in the sample if high = None.
high: [int, optional] Largest (signed) integer to be drawn from the distribution.
size: [int or tuple of ints, optional] Output shape. If the given shape is, eg, (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.Return: Array of random integers in the interval
[low, high)
or a single such random int if size not provided.
Code # 1:

Output:
Output 1D Array filled with random integers: [1 1 4 1]
Code # 2:
# Python program explaining
# numpy.random.random_integers () function
# numpy import
import
numpy as geek
# output array
out_arr
=
geek.random.random_integers (low
=
3
, size
=
(
3
,
3
))
print
( "Output 2D Array filled with random integers:"
, out_arr)
Output:
Output 2D Array filled with random integers: [[2 3 1] [2 2 3] [3 3 3]]
Code # 3:

Output:
Output 3D Array filled with random integers: [[[4 8 5 7] Output 3D Array filled with random integers: [[[5 1 5] [5 4 1]] [[3 6 4] [4 5 3]]]
A recipe for having fun and getting things done with the Raspberry Pi ...
12/08/2021
R for Everyone: Advanced Analytics and Graphics. ...
28/08/2021
Mark Lutz is the global leader in Python training, author of the oldest and bestselling Python texts, and a pioneer in the Python community since 1992.
Mark Lutz is the author of the found...
11/08/2021
I have developed this book to investigate Mesosbased cluster development and integration. I found that data center operating system (DCOS; and it’s commandline interface [CLI]) was a natural progr...
10/07/2020