I want to generate a 2D array of points with varying range lengths of x and y like so:
points = np.random.uniform(0, 300, (10000, 2))
This gives me 10000 points (with x and y) with range from 0 to 300. But I would like to limit the number for x and y separately. I would like x to range from 0 to 1280 and y to range from 0 to 720.
Is numpy capable of doing this, or I'm better off constructing such array by myself?
You can do:
np.random.uniform((0, 0), (1280 ,702), (10000, 2))
array([[1273.36065074, 593.61346294],
[ 861.09537599, 608.0452186 ],
[ 931.37010986, 529.71771209],
...,
[ 931.70239685, 442.04459329],
[ 764.29249852, 396.72112753],
[ 858.85217637, 437.34670284]])
Note that, as shown in the documentation, both the low and high values accept float or array_like of floats.
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