mercredi 27 octobre 2021

How to create a NumPy array of booleans with k% True values?

I know that we can create a NumPy array of boolean values with the following line of code:

np.random.choice(a=[False, True], size=(N,))

But what if I want to specify that I want this random array to have around 60% (or more generally k%) True values?




Aucun commentaire:

Enregistrer un commentaire