The OpenD Programming Language

mir.random.engine.xorshift

$(TR $(TDNW $(LREF Xorshift1024StarPhi)) $(TD <tt class="inline-code">xorshift1024*&#966;</tt>: when something larger than <tt class="inline-code">xoroshiro128+</tt> is needed)) $(TR $(TDNW $(LREF Xorshift64Star32)) $(TD <tt class="inline-code">xorshift64*/32</tt>: internal state of 64 bits and output of 32 bits))

$(TR $(TDNW $(LREF Xorshift192)) $(TD Generator from Marsaglia's paper combining 160-bit xorshift with a counter)) $(TR $(TDNW $(LREF Xorshift)) $(TD An alias to one of the generators in this package))

Generators

Generator nameDescription
Xorshift32 .. Xorshift160Basic xorshift generator with n bits of state (32, 64, 96, 128, 160)

$(TR $(TDNW $(LREF XorshiftStarEngine)) $(TD <tt class="inline-code">xorshift*</tt> generator with any word size and any number of bits of state.)) $(TR $(TDNW $(LREF XorshiftEngine)) $(TD <tt class="inline-code">xorshift</tt> generator with any word size and any number of bits of state.))

Generic Templates

Template nameDescription

Members

Aliases

Xorshift1024StarPhi
alias Xorshift1024StarPhi = XorshiftStarEngine!(ulong, 1024, 31, 11, 30, 0x9e3779b97f4a7c13uL)

Define XorshiftStarEngine with well-chosen parameters for large simulations on 64-bit machines.

Xorshift32
alias Xorshift32 = XorshiftEngine!(32, 13, 17, 15)

Define XorshiftEngine generators with well-chosen parameters for 32-bit architectures. Xorshift is an alias of one of the generators in this module.

Xorshift64Star32
alias Xorshift64Star32 = XorshiftStarEngine!(ulong, 64, 12, 25, 27, 2685821657736338717uL, uint)

Generates 32 bits of output from 64 bits of state. A fast generator with excellent statistical properties for memory-constrained situations where more than 64 bits of state would be too much and generating only 32 bits with each opCall will not cause a slowdown. If you need a generator with 64 bits of state that produces output 64 bits at a time SplitMix64 is an option.

Xoshiro128StarStar_32 (from mir.random.engine.xoshiro)
alias Xoshiro128StarStar_32 = XoshiroEngine!(uint, 128, "**", 9, 11, 0, 7, 5, 9) via public import mir.random.engine.xoshiro : Xoshiro256StarStar, Xoshiro128StarStar_32, XoshiroEngine, Xoroshiro128Plus;

32-bit-oriented xoshiro** with 128 bits of state. In general Xoshiro256StarStar is preferable except if you are tight on space <em>and</em> know that the generator's output will be consumed 32 bits at a time. (If you need a generator with 128 bits of state that is geared towards producing 64 bits at a time, Xoroshiro128Plus is an option.) 32 bit output. 128 bits of state. Period of 2^^128-1. 4-dimensionally equidistributed. None of its bits fail binary rank tests and it passes tests for Hamming-weight dependencies introduced in the xoshiro paper. From the authors:

Xoshiro256StarStar (from mir.random.engine.xoshiro)
alias Xoshiro256StarStar = XoshiroEngine!(ulong, 256, "**", 17, 45, 1, 7, 5, 9) via public import mir.random.engine.xoshiro : Xoshiro256StarStar, Xoshiro128StarStar_32, XoshiroEngine, Xoroshiro128Plus;

xoshiro256** (XOR/shift/rotate) as described in Scrambled linear pseudorandom number generators (Blackman and Vigna, 2018). 64 bit output. 256 bits of state. Period of 2^^256-1. 4-dimensionally equidistributed. It is 15% slower than xoroshiro128+ but none of its bits fail binary rank tests and it passes tests for Hamming-weight dependencies introduced in the linked paper. From the authors:

Structs

Xoroshiro128Plus (from mir.random.engine.xoshiro)
struct Xoroshiro128Plus via public import mir.random.engine.xoshiro : Xoshiro256StarStar, Xoshiro128StarStar_32, XoshiroEngine, Xoroshiro128Plus;

xoroshiro128+ (XOR/rotate/shift/rotate) generator. 64 bit output. 128 bits of state. Period of (2 ^^ 128) - 1.

XorshiftEngine
struct XorshiftEngine(UIntType, uint bits, int sa, int sb, int sc)

Xorshift generator. Implemented according to Xorshift RNGs (Marsaglia, 2003) with Sebastino Vigna's optimization for large arrays.

XorshiftStarEngine
struct XorshiftStarEngine(StateUInt, uint nbits, int sa, int sb, int sc, StateUInt multiplier, OutputUInt = StateUInt)

Template for the xorshift* family of generators (Vigna, 2016; draft 2014).

XoshiroEngine (from mir.random.engine.xoshiro)
struct XoshiroEngine(UIntType, uint nbits, string scrambler, uint A, uint B, uint I, uint R, UIntType S, UIntType T) via public import mir.random.engine.xoshiro : Xoshiro256StarStar, Xoshiro128StarStar_32, XoshiroEngine, Xoroshiro128Plus;

Template for the xoshiro family of generators. See the paper introducing xoshiro and xoroshiro.

Templates

XorshiftStarEngine
template XorshiftStarEngine(StateUInt, uint nbits, int sa, int sb, int sc, StateUInt multiplier, OutputUInt = StateUInt)

Template for the xorshift* family of generators (Vigna, 2016; draft 2014).

Meta

Authors

Masahiro Nakagawa, Ilya Yaroshenko (rework), Nathan Sashihara