I am interested to get an equally-sized group of indices. For example I have the following Python code:
import numpy as np
p = 2
n = 10
labels = np.random.randint(p, size=n)
The code above will create 10
labels (0
and 1
values) but not necessarily that the total number of 0's
is equal to the total number of 1's
. What do I need is to automatically obtain the same number: for example 0 1 0 0 1 1 0 1 0 1
(where there are really five 0's
and five 1's
). The same concept of the example above can be generalized for any p
and n
such that n/p
is an integer.
Any help will be very appreciated!