What is the best way to sample uniformly from an purely open or closed interval. #20527
-
What is the best way to achieve purely open scope ( Do we have to rely on limiting values/precision of the dtype? xs = jax.random.uniform(key, 1000, minval = minx+TINIEST_FLOAT, maxval=maxx) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can see how
Generating uniform random numbers with an exclusive minimum value would not be easy to do directly: it would essentially involve generating all mantissas except zero, which is difficult to do in a non-iterative fashion given source randomness coming from random bits. The easiest way to do this will probably be using a variation of what you suggested at the end of your question; for example with |
Beta Was this translation helpful? Give feedback.
You can see how
jax.random.uniform
is implemented here: https://github.com/google/jax/blob/16b3f00e42122d6be07a5bb1f8025fe4e3d1dd47/jax/_src/random.py#L425-L436floats
here are floating point numbers with an exponent of zero, lying between 0 (inclusive) and 1 (exclusive): they are then shifted to be betweenminval
(inclusive) andmaxval
(exclusive).Generating uniform random numbers with an exclusive minimum value would not be easy to do directly: it would essentially involve generating all mantissas except zero, which is difficult to do in a non-iterative fashion given source randomness coming from random bits.
The easiest way to do this will probably be using a variation of what you sug…