I was trying to use numpy.random.uniform to pick a real number on (-1, 1), but I noticed that the upper bound 1 is excluded. Is there any way to include the upper bound as well?
## -------------------- uniform distribution -------------------
def uniform(self, a, b):
"Get a random number in the range [a, b) or [a, b] depending on rounding."
return a + (b-a) * self.random()
If you want to keep by definition the uniform distribution you can force the rounding up to a certain digit with the round function, to have a chance to reach 1 by chance.
round(number, number of digits)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With