impureRandomImpure random number generator (with hidden state vector) |
This information is part of the Modelica Standard Library maintained by the Modelica Association.
r = impureRandom(id);
Returns a uniform random number in the range 0 < random ≤ 1 with the xorshift1024* algorithm. The dummy input Integer argument id must be the output argument of a call to function initializeImpureRandom, in order that the sorting order is correct (so that impureRandom is always called after initializeImpureRandom). For every call of impureRandom(id), a different random number is returned, so the function is impure.
parameter Integer seed; Real r; function random = impureRandom (final id=id); protected Integer id; equation // Initialize the random number generator when initial() then id = initializeImpureRandom(seed, time); end when; // Use the random number generator when sample(0,0.001) then r = random(); end when;
initializeImpureRandom, Random.Generators
This function is impure!
id |
Type: Integer Description: Identification number from initializeImpureRandom(..) function (is needed for correct sorting) |
---|
y |
Type: Real Description: A random number with a uniform distribution on the interval (0,1] |
---|