lundi 3 décembre 2018

How to return a NumPy array with m rows of n random integer values between 0 and 99 in Python?

I am trying to return an array that takes m, rows, of n, a random integer n, however, I am not sure how to do this. Do I need to set m = to random user input? And n = random integer 0-99. This is the code I have however, instead of me telling the array to be 6 rows of 7 random numbers how do I replace it with m and n and have it work using a random number of rows and integers?

import numpy as np
def gen_matrix(m,n):
m= 
return np.random.rand(6,7)*100
random_matrix = numpy.random.randint(0,max_val, 
(<num_rows>,<num_cols>))




Aucun commentaire:

Enregistrer un commentaire