[erlang-questions] RNG algorithm choice for uniform natural numbers

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu Aug 2 18:25:11 CEST 2018


On Thu, Aug 02, 2018 at 06:10:24PM +0200, Raimo Niskanen wrote:
> On Thu, Aug 02, 2018 at 02:19:17PM +0200, Krzysztof Jurewicz wrote:
> > I’m looking for an algorithm to perform a transparent, reproducible generation of an uniform sequence of natural numbers. There are three RNG algorithms documented in the rand module:
> > 
: :
> 
> I have a pull request for Xoroshiro928** that is a reworked Xoroshiro1024**
> with 58-bit word size, exactly because of speed reasons.  For the next
> step I was thinking about rewriting Xoroshiro256** to 58-bit, but the
> resulting algorighm would not be much faster than Xoroshiro928**,
> it would only have smaller state space, hopefully.  So I am not certain
> that it would be worth implementing.
> 
>     https://github.com/erlang/otp/pull/1857

To get you platform interoperability I could publish the C code I used as
reference for writing Xoroshiro928** in Erlang.
Yes there is a C implementation of it!


> 
> I have never thought about implementing the new 64-bit word size generators
> since nobody has asked for inter-platform compatibility before, and you still
> have to be careful with bit compatibility.  It is only when you request
> the generator word size range that you get the raw numbers.  And for
> floating point if you are lucky that both platforms use the same bits
> (low/high/middle).
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list