How to create a matrix with random numbers in NumPy

To create a matrix with random numbers, we can use random.random(size) function.

For example:

>>> import numpy as np
>>> np.random.random((3,))
array([ 0.55852091, 0.44623939, 0.05024937])
>>> np.random.random((3,2))
array([[ 0.6406884 , 0.05415084],
 [ 0.62747089, 0.00123648],
 [ 0.99915481, 0.42836407]])

,