.Modelica.Math.Random.Utilities.initializeImpureRandom

Information

Syntax

id = initializeImpureRandom(seed;

Description

Generates a hidden initial state vector for the Xorshift1024star random number generator (= xorshift1024* algorithm), from Integer input argument seed. Argument seed can be given any value (including zero or negative number). The function returns the dummy Integer number id. This number needs to be passed as input to function impureRandom, in order that the sorting order is correct (so that impureRandom is always called after initializeImpureRandom). The function stores a reasonable initial state vector in a C-static memory by using the Xorshift64star random number generator to fill the internal state vector with 64 bit random numbers.

Example

  parameter Integer seed;
  Real r;
  function random = impureRandom (final id=id);
protected 
  Integer id = initializeImpureRandom(seed);
equation
  // Use the random number generator
  when sample(0,0.001) then
     r = random();
  end when;

See also

Utilities.impureRandom, Random.Generators

Interface

function initializeImpureRandom
  extends Modelica.Icons.Function;
  input Integer seed "The input seed to initialize the impure random number generator";
  output Integer id "Identification number to be passed as input to function impureRandom, in order that sorting is correct";
end initializeImpureRandom;

Revisions

Date Description
June 22, 2015
DLR logo Initial version implemented by A. Klöckner, F. v.d. Linden, D. Zimmer, M. Otter.
DLR Institute of System Dynamics and Control

Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f