
functioninitializeImpureRandom
Initializes the internal state of the impure random number generator
Extends from Modelica.Icons.Function (Icon for functions).
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
Outputs
| Type | Name | Default | Description |
| Integer | id | | Identification number to be passed as input to function impureRandom, in order that sorting is correct |
Contents
| Name | Description |
setInternalStateprotected | Stores the given state vector in an external static variable |
Revisions
| Date | Description |
| June 22, 2015 |
|