Generate random array of floats between a range

2019-01-23 22:24发布

This might be a silly question but I haven't been able to find a function to generate an array of random floats of a given length between a certain range.

I've looked at Random sampling but no function seems to do what I need.

random.uniform comes close but it only returns a single element, not a specific number.

This is what I'm after:

ran_floats = some_function(low=0.5, high=13.3, size=50)

which would return an array of 50 random non-unique floats (ie: repetitions are allowed) uniformly distributed in the range [0.5, 13.3].

Is there such a function?

7条回答
Luminary・发光体
2楼-- · 2019-01-23 23:29

This is the simplest way

np.random.uniform(start,stop,(rows,columns))
查看更多
登录 后发表回答