Modelica.Math.Random.Generators.Xorshift128plus

Random number generator xorshift128+

Information

Random number generator xorshift128+. This generator has a period of 2^128 (the period defines the number of random numbers generated before the sequence begins to repeat itself). For an overview, comparison with other random number generators, and links to articles, see Math.Random.Generators.

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

Package Content

Name Description
nState=4 The dimension of the internal state vector
Modelica.Math.Random.Generators.Xorshift128plus.initialState initialState Returns an initial state for the xorshift128+ algorithm
Modelica.Math.Random.Generators.Xorshift128plus.random random Returns a uniform random number with the xorshift128+ algorithm

Modelica.Math.Random.Generators.Xorshift128plus.initialState Modelica.Math.Random.Generators.Xorshift128plus.initialState

Returns an initial state for the xorshift128+ algorithm

Information

Syntax

state = Xorshift128plus.initialState(localSeed, globalSeed);

Description

Generates an initial state vector for the Xorshift128plus random number generator (= xorshift128+ algorithm), from two Integer numbers given as input (arguments localSeed, globalSeed). Any Integer numbers can be given (including zero or negative number). The function returns a reasonable initial state vector with the following strategy:

The Xorshift64star random number generator is used to fill the internal state vector with 64 bit random numbers.

Example

  parameter Integer localSeed;
  parameter Integer globalSeed;
  Integer state[Xorshift128plus.nState];
initial equation
  state = initialState(localSeed, globalSeed);

See also

Random.Generators.Xorshift128plus.random.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
localSeedThe local seed to be used for generating initial states
globalSeedThe global seed to be combined with the local seed

Outputs

NameDescription
state[nState]The generated initial states

Modelica.Math.Random.Generators.Xorshift128plus.random Modelica.Math.Random.Generators.Xorshift128plus.random

Returns a uniform random number with the xorshift128+ algorithm

Information

Syntax

(r, stateOut) = Xorshift128plus.random(stateIn);

Description

Returns a uniform random number in the range 0 < random ≤ 1 with the xorshift128+ algorithm. Input argument stateIn is the state vector of the previous call. Output argument stateOut is the updated state vector. If the function is called with identical stateIn vectors, exactly the same random number r is returned.

Example

  parameter Integer localSeed;
  parameter Integer globalSeed;
  Real r;
  Integer state[Xorshift128plus.nState];
initial equation
  state = initialState(localSeed, globalSeed);
equation
  when sample(0,0.1) then
    (r, state) = random(pre(state));
  end when;

See also

Random.Generators.Xorshift128plus.initialState.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
stateIn[nState]The internal states for the random number generator

Outputs

NameDescription
resultA random number with a uniform distribution on the interval (0,1]
stateOut[nState]The new internal states of the random number generator
Automatically generated Thu Dec 19 17:20:25 2019.