Issue
How can I sample random floats on an interval [a, b] in numpy? Not just integers, but any real numbers. For example,
random_float(5, 10)
would return random numbers between [5, 10]
. thanks.
Solution
The uniform distribution would probably do what you are asking.
np.random.uniform(5,10) # A single value
np.random.uniform(5,10,[2,3]) # A 2x3 array
Answered By – Ken
Answer Checked By – Mary Flores (BugsFixing Volunteer)