Generating Random Matrices with Numpy

  • Share this:

Code introduction


This function generates a random matrix of specified number of rows and columns using numpy.


Technology Stack : numpy

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random
from datetime import datetime
import numpy as np

def generate_random_matrix(rows, cols):
    # This function generates a random matrix of given rows and columns using numpy.
    return np.random.rand(rows, cols)                
              
Tags: