Python Numpy random ranf()














































Python Numpy random ranf()



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.ranf(size=None)
Description : The function random sampling is a module present in the NumPy library. This module contains the functions which are used for generating random numbers and it returns an array of specified shapes and fills it with random floats in the half-open interval [0.0, 1.0). This module contains some simple random data generation methods and some permutation and distribution functions, and random generator functions.
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.

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.ranf(size=None)

Example :
Code :

# numpy.random.ranf() function # importing numpy import numpy as geek # output array out_arr = geek.random.ranf(size =(3,2)) print ("Output 2D Array filled with random floats : ", out_arr)

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

Output :


Comments