Pierre GM wrote:
a[a<0] = numpy.random.normal(0,1)
This is a neat construct that I didn't realize was possible. However, it has the undesirable (in my case) effect of placing a single new random number in each locations where a<0. While this could work, I ideally need a different random number chosen for each replaced value. Does that make sense?
Certainly. How about this?
mask = (a<0) a[mask] = numpy.random.normal(0, 1, size=mask.sum())