Here's part of the code I'm working on:
def get_noise(measures, errors):
noisy_measures = []
for i,j in zip(measures, errors):
added = i + np.random.normal(scale = j)
while added < 0:
added = i + np.random.normal(scale = j) # Question Here!
noisy_measures.append()
return noisy_measures
The number added is a sum of fixed number measures and a random number sampled from a normal distribution, which might be negative. I wonder how can I add some conditions to make added non-negative? I'm trying to do something marked in the code but it seems like that doesn't work.
How can I resample the random value until added is non-negative?