p = 0.01
slot_duration = 10
test_duration = 60
timeslots_left = test_duration * 1000 * 1000 / 20
transmission_array = []
while timeslots_left >= 0:
    rand_num = np.random.choice((0, 1), p=[1 - p, p])
duration = slot_duration if rand_num == 1 else 1
transmission_array.extend([rand_num] * 400 * duration)
timeslots_left -= duration
Efficient array operations in python