I have two pairs of min and max values for two variables. I want to draw n random samples from a uniform distribution of these two variables, lying between their min and max values. For example:
min_x = 0
max_x = 10
min_y = 0
max_y = 20
Let's say I draw three samples. These could be:
[(4, 15), (8, 9), (0, 19)] # First value is drawn randomly with uniform probability between min_x and max_x, second value is drawn similarly between min_y and max_y
How can I achieve this with numpy in a simple way?
I've come up with this:
>>> min_x = 0
>>> max_x = 10
>>> min_y = 0
>>> max_y = 20
>>> sample = np.random.random_sample(2)
>>> sample[0] = (sample[0]) * max_x - min_x
>>> sample[1] = (sample[1]) * max_y - min_y
>>> sample
array([ 1.81221794, 18.0091034 ])
but I feel like there should be a simpler solution.
EDIT: Not a duplicate. The answers of the suggested duplicate question deals with integers.