.AdvancedNoise.Sources.SignalBasedNoise

Information

A summary of the properties of the noise blocks is provided in the documentation of package Modelica.Blocks.Noise. This SignalBasedNoise 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.

The generated random numbers of this block are a function of the input signal. Blocks with different input signals produce uncorrelated noise. This can be used to define e.g. the roughness of a railway track. The random values provided at the output of a SignalBasedNoise instance depend (a) on the actual input signal in the current 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 for the same input signal.

Parameters that need to be defined

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

Parameter Description
useTime If useTime = true, then the input signal is replaced by the current simulation time. This is the default. If useTime = false, then an input connector is used, which defines the ordinate of the random signal. For each value of the input signal, a different random number is generated.
samplePeriod Random values are drawn on a periodic grid over the input signal. The period of this grid is defined with this parameter. The unit of the samplePeriod corresponds to the unit of the input signal. If useTime=true, then the samplePeriod defines a sample Period in [s]. As a result of this pseudo-sampling, the highest frequency fmax contained in the generated noise is fmax = 1/samplePeriod. By default, no events are generated. In between, the noise is linearly interpolated at the drawn random values.

As a simple demonstration, see example Examples.SignalBasedNoise. In the next diagram, a simulation result is shown with a ramped input signal repeated every second. The generated random numbers then also repeat every second!

Diagram SignalBasedNoise.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.

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. The example uses the block TimeBasedNoise, but the results also hold for SignalBasedNoise. 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, 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 generate different random signals with every 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. This might be useful, if you use the noise block to model the roughness of a road and the road should be the same for every vehicle.
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.
signalOffset This parameter can be used to shift the input signal. This can be used, if you wish the pseudo-sampling (see parameter samplePeriod) to happen at specific values of the input signal.

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-04-18T18:15:58Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos