.Modelica_Noise.Math.Random.Utilities.impureRandom

Information

Syntax

r = impureRandom(id);

Description

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.

Example

  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);
  end when;

  // Use the random number generator
  when sample(0,0.001) then
     r = random();
  end when;

See also

initializeImpureRandom, Random.Generators

Note

This function is impure!

Interface

function impureRandom
  input Integer id "Identification number from initializeImpureRandom(..) function (is needed for correct sorting)";
  output Real y "A random number with a uniform distribution on the interval (0,1]";
end impureRandom;

Revisions

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


Generated at 2024-12-28T19:26:00Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos