vendredi 8 mai 2015

Full-range random number in Python

I'm generating a series of random floats using this line:

random.random()*(maxval-minval) + minval

It works, but if I want a completely random float, i.e. in the [-inf,+inf] range, the above code returns NaN. Is there an elegant way to do it? I don't want to tamper with os.random() as it is machine-specific.




Aucun commentaire:

Enregistrer un commentaire