You can download this code by clicking the button below.
This code is now available for download.
This function generates a random matrix of specified size and data type.
Technology Stack : numpy
Code Type : Function
Code Difficulty : Intermediate
import numpy as np
def random_matrix(n, m, dtype=np.int32):
"""
Generate a random matrix of size n x m with specified data type.
"""
return np.random.randint(0, 100, size=(n, m), dtype=dtype)