samedi 26 septembre 2020

Initialize a np array randomly with a determined quantity of 1's and 0's

I want to initialize an array randomly with a certain quantity of 1's and 0's. The following code is all I've got. I just managed to initialize it with a random quantity of 1's and 0's, but I'd like to do it, for example (knowing that the matrix is 10x10) with 25 1's and 75 0's.

matrix = np.random.randint(2, size=(10,10))



Aucun commentaire:

Enregistrer un commentaire