I have a 1D (numpy) array with boolean values. for example:
x = [True, True, False, False, False, True, False, True, True, True, False, True, True, False]
The array contains 8
True values. I would like to keep, for example, exactly 3
(must be less than 8
in this case) as True values randomly from the 8
that exist. In other words I would like to randomly set 5
of those 8
True values as False.
A possible result can be:
x = [True, True, False, False, False, False, False, False, False, False, False, False, True, False]
How to implement it?