You can download this code by clicking the button below.
This code is now available for download.
This function generates a random matrix with specified number of rows and columns. The elements in the matrix are randomly generated floating-point numbers, with the default data type being np.float64.
Technology Stack : numpy
Code Type : Function
Code Difficulty : Intermediate
import numpy as np
def generate_random_matrix(rows, cols, dtype=np.float64):
"""
Generate a random matrix with specified number of rows and columns.
"""
return np.random.random((rows, cols), dtype=dtype)