Python Numpy random_integers()














































Python Numpy random_integers()



Description
NumPy generally stands for Numerical Python and it is a general purpose array processing package.it always provides a high performance multidimensional array object. Numpy is usually for creating an array of n dimensions.

Method Name :numpy.random.random_integers(low, high=None, size=None)
Description : The function for doing random sampling in NumPy and the method in Python returns a random integer value between the two lower and higher limits (including both limits) i.e. in the interval [low, high) provided as two parameters.It returns an array of specified shape and fills it with random integers from low (inclusive) to high (exclusive), i.e. in the interval [low, high)

In this article, I will tell you about the parameter and its description
Parameter Name: low
Description :int
The lowest integer is to be drawn from the distribution. But, it works as the highest integer in the sample if high=None.

Parameter Name: high
Description :int
Largest integer to be drawn from the distribution.

Parameter Name: size
Description : int or tuple of ints
If the given shape is, e.g., (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.

The first step would be to give syntax
command:
numpy.random.random_integers(low, high=None, size=None)

Example :
Code :
# numpy.random.random_integers() function # importing numpy import numpy as np # output array out_array = np.random.random_integers(low = 5, size =(5,5)) print ("Output 2D Array filled with random integers : ", out_array)

Output :
Example :
Code :
# numpy.random.random_integers() function # importing numpy import numpy as np # output array out_array = np.random.random_integers(1, 8, (3,3,9)) print ("Output 2D Array filled with random integers : ", out_array)

Output :


Comments