Numeric generators Shiro Kawai (05 Mar 2024 20:04 UTC)
Re: Numeric generators Antero Mejr (05 Mar 2024 21:42 UTC)
Re: Numeric generators Shiro Kawai (06 Mar 2024 00:28 UTC)
Re: Numeric generators Bradley Lucier (06 Mar 2024 01:39 UTC)

Re: Numeric generators Bradley Lucier 06 Mar 2024 01:39 UTC

On 3/5/24 7:27 PM, Shiro Kawai wrote:
> Floating point numbers are not distributed evenly in the numerical
> space, so if you try to sample numerically uniformly from the IEEE 754
> range, you tend to get only numbers of large exponents.  It might be
> better to sample uniformly from all possible floating point numbers
> (which is not numerically uniform), but good wording doesn't come
> immediately.

Very good point.

I was going to say that I sometimes want to sample integers with lengths
randomly chosen in some range, so it's a two-step process: choose a
random integer uniformly from an interval to give a length l, then
choose an random integer uniformly in the range [0,2^l).

In choosing random floating-point numbers, I sometimes want to choose
uniformly on a logarithmic scale, so to choose the exponent E uniformly
in a specific integer range, and then choose a floating-point mantissa M
uniformly in [1/2,1) to get the final result M * 2^E.

I don't know right now how to formalize this.

Brad