ОК, в свете вашего комментария, это должно работать лучше как пример того, как выбирать только пропорционально из каждого списка / массива:
import random
a1= '10001010111110001101010101'
a2= '00101010001011010010100010'
a1 = [int(t) for t in a1]
a2 = [int(t) for t in a2]
a1_one_locations= [idx for idx, v in enumerate(a1) if v==1]
a2_one_locations= [idx for idx, v in enumerate(a2) if v==1]
# lists of indices where 1 exists in each list...
print(a1_one_locations)
print(a2_one_locations)
n_samples = 6 # total desired
# 40% from a1, remainder from a2
a1_samples = int(n_samples * 0.4)
a2_samples = n_samples - a1_samples
a1_picks = random.sample(a1_one_locations, a1_samples)
a2_picks = random.sample(a2_one_locations, a2_samples)
# print results
print('indices from a1: ', a1_picks)
print('indices from a2: ', a2_picks)
Вывод:
[0, 4, 6, 8, 9, 10, 11, 12, 16, 17, 19, 21, 23, 25]
[2, 4, 6, 10, 12, 13, 15, 18, 20, 24]
indices from a1: [6, 21]
indices from a2: [10, 15, 4, 20]