I want to generate random float number in the range 0 and 0.0001
I tried:
from numpy import random
random.random(0, 0.0001)
But i got the error :
TypeError: random() takes at most 1 positional argument (2 given)
Then i tried :
from numpy import random
random.random(0.0001)
But i got the error : TypeError: 'float' object cannot be interpreted as an integer
How can i produce random numbers in this range ? [0, 0.0001]
CodePudding user response:
You can make use of random.uniform
to generate a float number between the given value.
import numpy as np
print(np.random.uniform(0, 0.0001))
CodePudding user response:
you can use random.uniform like this
import random
print(random.uniform(0, 0.0001))
CodePudding user response:
To get around this issue, you can generate a random number between 0 and 1 and divide the result by 10000.
from numpy import random
random.random() / 10000