Package Modelica.​Math.​Random.​Generators
Library of functions generating uniform random numbers in the range 0 < random <= 1.0 (with exposed state vectors)


This package contains various pseudo random number generators. A random number generator is a package that consists of the following elements:

The Generators package contains the xorshift suite of random number generators from Sebastiano Vigna (from 2014; based on work of George Marsaglia). The properties of these random number generators are summarized below and compared with the often used Mersenne Twister (MT19937-64) generator. The table is based on and on the articles:

Sebastiano Vigna: An experimental exploration of Marsaglia's xorshift generators, scrambled, 2014.
Sebastiano Vigna: Further scramblings of Marsaglia's xorshift generators, 2014.

Summary of the properties of the random number generators:

Property xorshift64* xorshift128+ xorshift1024* MT19937-64
Period 2^64 2^128 2^1024 2^19937
Length of state (# 32 bit integer) 2 4 33 624
Statistic failures (Big Crush) 363 64 51 516
Systematic failures (Big Crush) yes no no yes
Worst case startup > 1 call > 20 calls > 100 calls > 100000 calls
Run time (MT=1.0) 0.39 0.27 0.33 1.0

Further explanations of the properties above:

The xorshift random number generators are used in the following way in the Blocks.Noise package:

  1. Xorshift64star (xorshift64*) is used to generate the initial internal state vectors of the other generators from two Integer values, due to the very good startup properties.
  2. Xorshift128plus (xorshift128+) is the random number generator used by the blocks in Blocks.Noise. Since these blocks hold the internal state vector for every block instance, and the internal state vector is copied whenever a new random number is drawn, it is important that the internal state vector is short (and still has good statistical properties as shown in the table above).
  3. Xorshift1024star (xorshift1024*) is the basis of the impure function Math.Random.Utilities.impureRandom which in turn is used with Blocks.Noise.GlobalSeed. The internal state vector is not exposed. It is updated internally, whenever a new random number is drawn.

Note, the generators produce 64 bit random numbers. These numbers are mapped to the 52 bit mantissa of double numbers in the range 0.0 .. 1.0.

Extends from Modelica.​Icons.​Package (Icon for standard packages).

Package Contents

Xorshift1024starRandom number generator xorshift1024*
Xorshift128plusRandom number generator xorshift128+
Xorshift64starRandom number generator xorshift64*