Python Numpy sample()














































Python Numpy sample()



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.sample(size=None)
Description :The function for doing random sampling in NumPy. It will return an array of specified shapes and fill it with random floats in the half-open interval [0.0, 1.0).

In this article, I will tell you about the parameter and its description
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.

Parameter Name: sequence
Description : A sequence can be any type of sequence like as: list, set, range, etc.

Parameter Name: k
Description :The size of the returned list.

Return :The array of random floats in the interval [0.0, 1.0) or a single such random float if size not provided in the given output.

The first step would be to give syntax
command:
numpy.random.sample(size=None)

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

Output :
Example :
Code :
# numpy.random.sample() function # importing numpy import numpy as np # output array out_arr = np.random.sample(size =(3,5,5)) print ("Output 2D Array filled with random floats : ", out_arr)

Output :


Comments