.AdvancedNoise.Sources.TimeBasedNoise

Information

A summary of the properties of the noise blocks is provided in the documentation of package Modelica.Blocks.Noise. This TimeBasedNoise block generates reproducible noise at its output. The block can only be used if on the same or a higher hierarchical level, model Modelica.Blocks.Noise.GlobalSeed is dragged to provide global settings for all instances.

For every block instance, the internally used pseudo random number generator has its own state, and therefore the random values computed in different instances of the TimeBasedNoise block are uncorrelated. The random values provided at the output of a TimeBasedNoise instance depend (a) on the actual time instant, (b) on the instance name, and (c) on the settings of the respective instance (as well as the seetings in globalSeed, see above and below). By default, two or more instances produce different, uncorrelated noise at the same time instant.

Parameters that need to be defined

When using this block, at a minimum the following parameters must be defined:

Parameter Description
samplePeriod Random values are drawn periodically at the sample rate in [s] defined with this parameter. As a result, the highest frequency fmax contained in the generated noise is fmax = 1/samplePeriod*. By default, time events are generated only at every 100 sample instant. In between, the noise is linearly interpolated at the drawn random values.

As a simple demonstration, see example Examples.TimeBasedNoise. In the next diagram, a simulation result is shown for samplePeriod = 0.02 s, y_min = -1, y_max = 3:

Diagram TimeBasedNoise.png

Advanced tab: General settings

In the Advanced tab of the parameter menu, further options can be set. The general settings are shown in the next table:

Parameter Description
enableNoise = true, if noise is generated at the output of the block.
= false, if noise generation is switched off and the constant value y_off is provided as output.
y_off If enableNoise = false, the output of the block instance has the value y_off. Default is y_off = 0.0. Furthermore, if time < startTime, the output of the block is also y_off.
sampleFactor If the drawn random numbers are continuously interpolated (so interpolation ≠ Constant), then a time event is only generated at every sampleFactor sample instant. At such an event a buffer is filled with the next sampleFactor random values and interpolation takes place in this buffer. This approach speeds up the simulation considerably, in many cases (provided not too small relative tolerance is selected for the integrator). If interpolation = Constant, then sampleFactor is ignored and a time event is generated at every sample instant. If sampleFactor = 1, then a time event is also generated at every sample instant, independently of the selected interpolation method (which leads usually to a slow simulation).

Advanced tab: Random number properties

In the group "Random number properties", the properties of the random number generation are defined. By default, uniform random numbers with linear interpolation are used, and the random numbers are drawn with the pseudo random number generator algorithm "xorshift128+". This random number generator has a period of 2^128, has an internal state of 4 Integer elements, and has excellent statistical properties. If the default behavior is not desired, the following parameters can be set:

Parameter Description
distribution Defines the random number distribution to map random numbers from the range 0.0 ... 1.0, to the desired range and distribution. Basically, distribution is a replaceable function that provides the truncated quantile (= truncated inverse cumulative distribution function) of a random distribution. More details of truncated distributions can be found in the documentation of package Distributions.
interpolation Defines the type of interpolation between the random values drawn at sample instants. This is a replaceable package. The following interpolation packages are provided in package Interpolators:
  • Constant: The random values are held constant between sample instants.
  • Linear: The random values are linearly interpolated between sample instants.
  • SmoothIdealLowPass: The random values are smoothly interpolated with the sinc function. This is an approximation of an ideal low pass filter (that would have an infinite steep drop of the frequency response at the cut-off frequency 1/samplePeriod).
generator Defines the pseudo random number generator to be used. This is a replaceable package. The random number generators that are provided in package Generators can be used here. Properties of the various generators are described in the package description of the Generators package.

The different interpolation methods are demonstrated with example Examples.InterpolateRandomNumbers. A simulation result is shown in the next diagram:

Diagram InterpolationInterpolators.png

As can be seen, constant (constantNoise.y) and linear (linearNoise.y) interpolation respects the defined band -1 .. 3. Instead, smooth interpolation with the sinc function (smoothNoise.y) may violate the band slightly in order to be able to smoothly interpolate the random values at the sample instants. In practical applications, this is not an issue because the exact band of the noise is usually not exactly known.

The selected interpolation method does not change the mean value of the noise signal, but it changes its variance with the following factors:

Interpolation Variance factor
Constant 1.0
Linear 2/3 (actual variance = 2/3*<variance of constantly interpolated noise>)
SmoothIdealLowPass 0.979776342307764 (actual variance = 0.97..*<variance of constantly interpolated noise>)

The above table holds only if an event is generated at every sample instant (sampleFactor=1), or for very small relative tolerances. Otherwise, the variance depends also slightly on the step-size and the interpolation method of the integrator. Therefore, if the variance of the noise is important for your application, either change the distribution definition to take the factors above into account, or use only constant interpolation.

Advanced tab: Initialization

The random number generators must be properly initialized, especially that different instances of the noise block generate uncorrelated noise. For this purpose the following parameters can be defined.

Parameter Description
useGlobalSeed = true, if the seed (= Integer number) defined in the "inner GlobalSeed globalSeed" component is used for the initialization of the random number generators. Therefore, whenever the globalSeed defines a different number, the noise at every instance is changing.
= false, if the seed defined by globalSeed is ignored. For example, if aerodynamic turbulence is modelled with a noise block and this turbulence model shall be used for all simulation runs of a Monte Carlo simulation, then useGlobalSeed has to be set to false.
useAutomaticLocalSeed An Integer number, called local seed, is needed to initalize the random number generator for a specific block instance. Instances using the same local seed produce exactly the same random number values (so the same noise, if the other settings of the instances are the same). If useAut5omaticLocalSeed = true, the local seed is determined automatically as hash value of the instance name of the noise block. If useAutomaticLocalSeed = false, the local seed is defined explicitly by parameter fixedLocalSeed.
fixedLocalSeed If useAutomaticLocalSeed = false, the local seed to be used. fixedLocalSeed can be any Integer number (including zero or a negative number). The initialization algorithm produces a meaningful initial state of the random number generator, so the subsequently drawing of random numbers produce statistically meaningful numbers.
startTime The time instant at which noise shall be generated at the output y. For time < startTime, y = y_off. In some cases it is meaningful to simulate a certain duration until an approximate steady-state is reached. In such a case startTime should be set to a time instant after this duration.

Contents

NameDescription
 distributionRandom number distribution
 interpolationInterpolation method in grid of raw random numbers
 generatorRandom number generator

Revisions

Date Description
Sep. 4, 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 2024-11-22T19:25:38Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos