Python Numpy random.rand can generate a multidimensional random array matrix of size equal to the provided input tuple. So, for example, if you provide (3,2) then it will generate a matrix of 3 rows and 2 columns. Similarly, for 3 tuples like (4,3,2), it will generate a matrix with 4 matrixes of size (3,2).

np.random.rand(4,3)

The output of np.random.rand(4,3) will be –

array([
  [0.57357548, 0.19444858, 0.75578484],
  [0.93784862, 0.24637747, 0.67862654],
  [0.92367486, 0.16787733, 0.92856422],
  [0.23546244, 0.23296524, 0.99945754],
])

You can see there are 4 rows and 3 columns.

    Tweet this to help others

Comments

About the Author

akamit

I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles