vendredi 11 novembre 2022

How to generate a random 0's and 1's Matrix in which the sum of each row equals 10 in python

How can I generate a Random (N*M) 0's and 1's Matrix in which the sum of each row equals to 10? (in python using numpy)

for example for 10*10(N*M) matrix we can use:

import numpy as np
np.random.randint(2, size=(10, 10))

but I want sum of each rows equals to 10




Aucun commentaire:

Enregistrer un commentaire