mardi 13 mars 2018

Python call a function and only save the positive result [duplicate]

This question already has an answer here:

I want to get a random value from the positive side of a normal distribution.

mu, sigma = 0, 400 # mean and standard deviation

s=np.random.normal(mu, sigma)

I want to save it to s if s is positive:

tried:

s=np.random.normal(mu, sigma)
if s>=0:
    t=s

however if s is negative, it will not give a t new result.




Aucun commentaire:

Enregistrer un commentaire