Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

This is a port of xoshiro256** from C to Haskell. The documentation and comments below come from the original C sources.

Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)

To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

# Seeding the generator

mkState :: Word64 -> Word64 -> Word64 -> Word64 -> State Source #

Create an initial state from a seed.

Raises an exception if the initial seed is all zeros.

`>>>`

*** Exception: The state must be seeded so that it is not zero everywhere.`mkState 0 0 0 0`

`>>>`

mkState 1 2 3 4`mkState 1 2 3 4`

# Generating random numbers

next :: State -> (Word64 -> State -> a) -> a Source #

This is xoshiro256** 1.0, our all-purpose, rock-solid generator. It has excellent (sub-ns) speed, a state (256 bits) that is large enough for any parallel application, and it passes all tests we are aware of.

For generating just floating-point numbers, xoshiro256+ is even faster.

`>>>`

`let state = mkState 1 2 3 4`

`>>>`

11520`next state (\rand _state' -> rand)`

Note: When porting to Haskell, we've explicitly chosen to make the API of
`next`

in CPS-style (i.e., using a callback) to avoid always allocating a
tuple for the result.

If you'd rather just have a tuple, you can pass `(,)`

as the callback:

`>>>`

(11520,mkState 7 0 262146 211106232532992)`next state (,)`

# Jumps

jump :: State -> State Source #

This is the jump function for the generator. It is equivalent to 2^128 calls to next(); it can be used to generate 2^128 non-overlapping subsequences for parallel computations.

Note: This function is not yet implemented in Haskell.

longJump :: State -> State Source #

This is the long-jump function for the generator. It is equivalent to 2^192 calls to next(); it can be used to generate 2^64 starting points, from each of which jump() will generate 2^64 non-overlapping subsequences for parallel distributed computations.

Note: This function is not yet implemented in Haskell.