Random number generators discussion

Random number generators | www.agner.org

Multiplying uniform floats to obtain random ints
Author: Agner Date: 2015-11-16 14:01
Yes, this is what I am referring to. Your method still has the quantization error described in my paper.

If r is a power of 2, then you can simply use (C language:)
y = x & (r-1);
where x is random bits.

If r is not a power of 2, then you can use the method you describe, or this method which is faster:

y = ((uint32_t)x * (uint64_t)r) >> 32;

Both methods have the same quantization error. If you want exactness then use the rejection method described in my paper (which will be published in the next issue of Journal of Modern Applied Statistical Methods).

 
thread Multiplying uniform floats to obtain random ints new - Nathan Kurz - 2015-11-15
last replythread Multiplying uniform floats to obtain random ints - Agner - 2015-11-16
last replythread Multiplying uniform floats to obtain random ints new - Nathan Kurz - 2015-11-16
last reply Multiplying uniform floats to obtain random ints new - Agner - 2015-11-17