Let’s see how to generate random matrix using the NumPy library in Python.

## Using Random Rand method

To generate Numpy matrix populated with random numbers use random Numpy module.

import numpy as np random_array = np.random.rand(3, 3) print(random_array)

As you can see, the rand function syntax requires you to provide just the number of rows and columns.

## Using Random Randint method

However, there is also the possibility to generate an array in a different way. You can populate your array with integers within a specified range using the randint function.

import numpy as np random_array = np.random.randint(0, 7, size=10) print(random_array)

Based on this code you probably know. 0 is low value and 7 is max one. Size of array is 10.