Random Matrix Generator

  • Share this:

Code introduction


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)                
              
Tags: