This question already has an answer here:
I want to create an array with fixed number of True and False. Here is the code to generate random array of True and False:
np.random.choice(a=[False, True], size=(N, N), p=[p, 1-p])
This code will give me an array of N*N with probability of p for False and 1-p for True. Now I want to set fixed number of False and True. How can I do it in Python?
Here are some other related questions but are not the same as what I'm asking:
Example but without specific number of True and False
Aucun commentaire:
Enregistrer un commentaire