Package Modelica.​Math.​Random.​Generators.​Xorshift64star
Random number generator xorshift64*

Information

Random number generator xorshift64*. This generator has a period of 2^64 (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 Contents

NameDescription
initialStateReturns an initial state for the xorshift64* algorithm
randomReturns a uniform random number with the xorshift64* algorithm

Package Constants

TypeNameValueDescription
IntegernState2The dimension of the internal state vector

Function Modelica.​Math.​Random.​Generators.​Xorshift64star.​initialState
Returns an initial state for the xorshift64* algorithm

Information

Syntax

state = Xorshift64star.initialState(localSeed, globalSeed);

Description

Generates the initial state vector state for the Xorshift64star random number generator (= xorshift64* 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:

If both input arguments are zero, a fixed non-zero value is used internally for localSeed. According to xorshift.pdf, the xorshift64* random number generator generates statistically random numbers from a bad seed within one iteration. To be on the safe side, actually 10 random numbers are generated and the returned state is the one from the last iteration.

Example

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

See also

Random.Generators.Xorshift64star.random.

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

Inputs

TypeNameDescription
IntegerlocalSeedThe local seed to be used for generating initial states
IntegerglobalSeedThe global seed to be combined with the local seed

Outputs

TypeNameDescription
Integerstate[nState]The generated initial states

Function Modelica.​Math.​Random.​Generators.​Xorshift64star.​random
Returns a uniform random number with the xorshift64* algorithm

Information

Syntax

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

Description

Returns a uniform random number r in the range 0 < r ≤ 1 with the xorshift64* 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[Xorshift64star.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.Xorshift64star.initialState.

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

Inputs

TypeNameDescription
IntegerstateIn[nState]The internal states for the random number generator

Outputs

TypeNameDescription
RealresultA random number with a uniform distribution on the interval (0,1]
IntegerstateOut[nState]The new internal states of the random number generator

Generated 2018-12-12 12:14:35 EST by MapleSim.