mercredi 12 février 2020

Can I draw a random value from uniform distribution on an open interval?

I would like to use numpy to draw a random value from a continuous uniform distribution from the open range (0,5). My eyes have fallen on numpy.random.uniform(0,5). However, this includes according to the documentation the closed interval [0,5] or a semi-open interval [0,5) depending on who you're talking to.

I have looked at many posts and so far not found good answers. Answer so far include: you dont need to use a fully open range because drawing the start and end values is impossible or there are debates about whether it is actually semi-open or fully closed. The best solution I thought about so far is:

import numpy as np
rn = np.random.uniform(sys.float_info.epsilon, 5-sys.float_info.epsilon)
print(rn)

or using numpy's next_after:

import numpy as np
rn = np.random.uniform(np.nextafter(0,1), np.nextafter(5,0))
print(rn)

Obviously, I would not bother everyone if I did not have a very good reason for drawing (in theory) from a completely open range. I would really appreciate thoughts about how I could plausibly argue that I am drawing a random value from a continuous uniform distribution on the completely open interval (0,5).

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire