I want to fill randomly a numpy array with arbitrary size with zeroes and ones. On each entry there should be a one with probability p.
for x in range(l):
rn = numpy.random.uniform(0, 1)
if rn <= p:
arr[x] = 1.0
else:
arr[x] = 0.0
Do you know a faster way to do this?