Engee documentation

Moving RMS

Moving average.

moving rms

Description

The Moving RMS block calculates the moving RMS value of the input signal for each channel, regardless of time.

The block uses either the sliding window method or the exponential weighting method to calculate the moving RMS value.

In the sliding window method, a window of a given length is moved through the data step by step, and the block calculates the RMS value from the data in the window.

In the exponential weighting method, the block squares successive values of the input signal, multiplies them by a set of weighting factors, and sums the weighted data. The block then calculates the RMS value by extracting the square root of the sum.

Ports

Input

x - data input
vector | matrix

The block calculates the moving average of the data specified on this input port. The block accepts multichannel input data of dimension to , where and , with real or complex values.

If the Allow arbitrary frame length for fixed-size input signals parameter is shown but not selected, and the input signal is fixed-size, the frame length must be a multiple of the jump size, which is defined as the difference between the window length and the overlap length. In all other cases the length of the input frame can be arbitrary.

The block accepts input signals of variable size (the frame length changes during the modelling process). When a variable size signal is input, the length of the signal frame can be arbitrary.

This port has no name unless the Method parameter is set to Exponential weighting and the Specify forgetting factor from input port parameter is enabled.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128.

Support for complex numbers: Yes

λ - forgetting factor
positive real scalar from 0 to 1

The forgetting coefficient determines how much weight past data had. With a forgetting coefficient of 0.9, old data has more weight than with a forgetting coefficient of 0.1. A forgetting rate of 1.0 means infinite memory - all previous samples have the same weight.

Dependencies

This port appears if the Method parameter is set to `Exponential weighting' and the Specify forgetting factor from input port parameter is enabled.

Data types: Float64 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32

Output

Port_1 - moving average output
vector | matrix

Moving average returned as a vector or matrix. The block calculates the moving average based on the settings of the Method parameter, using either the sliding window method or the exponential weighting method.

The table provides details of the output dimensions.

Input signal Input signal dimensions Output signal dimensions, Allow arbitrary frame length for fixed-size input signals shown Output signal dimensions, Allow arbitrary frame length for fixed-size input signals not shown

Fixed-size signal

at , where is a multiple of the jump size (window length - overlap length)

(jump size) at

at

Fixed size signal

at where is not a multiple of the jump size (window length - slab length)

ceil( jump size) to if the parameter Allow arbitrary frame length for fixed-size input signals is enabled. If this parameter is switched off, the block gives an error

at

Variable-size signal

at

ceil( jump-size") at

on

When the output has an upper bound on the size of ceil( jump size) at , during the simulation the size of the first dimension changes within this bound and the size of the second dimension remains constant.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128.

Support for complex numbers: Yes

Parameters

Main

Method - averaging method
Sliding window (by default) | Exponential weighting
  • Sliding window - a window of Window length is moved over the input data along each channel. For each sample over which the window is moved, the block calculates the average value over the data in the window.

  • Exponential weighting - the block multiplies the samples by a set of weighting factors. The value of the weighting factors decreases exponentially as the age of the data increases, but the value never reaches zero. The algorithm summarises the weighted data to calculate the mean.

Specify window length - specify window length
enabled (by default) | enabled

If this checkbox is selected, the sliding window length will be equal to the value specified in the Window length parameter. If unchecked, the sliding window length will be infinite. In this mode, the block calculates the average value of the current sample and all previous samples in the channel.

Dependencies

To enable this parameter, set the Method parameter to Sliding window.

Window length - sliding window length
4 (by default) | positive integer.

Specifies the length of the sliding window in the samples.

Dependencies

To enable this parameter, set the Method parameter to Sliding window and select the Specify window length checkbox.

Overlap length - the length of overlap between windows
3 (by default) | non-negative integer.

Specifies the overlap length between windows as a non-negative integer. The overlap length value ranges from 0 to Window length-1.

Dependencies

To enable this parameter, set the Method parameter to Sliding window and select the Specify window length checkbox.

Allow arbitrary frame length for fixed-size input signals - allow arbitrary frame length for fixed-size input signals
off (By default) | `on

Specify whether fixed-size input signals (whose size does not change during simulation) can have an arbitrary frame length, where the frame length need not be a multiple of the jump size. The jump size is defined as the difference between the values of the Window length and Overlap length parameters. The block uses this parameter only for input signals of fixed size and ignores it if the input signal has a variable size.

When the input signal has a variable size, the signal can have an arbitrary frame length, i.e. the frame length must not be a multiple of the jump size.

For fixed size input signals:

  • If you select Allow arbitrary frame length for fixed-size input signals, the frame length of the signal does not have to be a multiple of the jump size. If the input signal is not a multiple of the jump size, the output is usually a variable-sized signal. Therefore, to support arbitrary input signal size, the block must also support variable-size operations, which can be enabled by selecting Allow arbitrary frame length for fixed-size input signals.

  • If Allow arbitrary frame length for fixed-size input signals is disabled, the input frame length must be a multiple of the jump size.

Dependencies

To enable this parameter, set the Method parameter to Sliding window and select the Specify window length checkbox.

Specify forgetting factor from input port - specify forgetting factor from input port
off (by default) | `on

When this checkbox is selected, the forgetting factor is entered through the λ port. When unchecked, the forgetting factor is entered via the Forgetting factor parameter.

Dependencies

To enable this parameter, set the Method parameter to `Exponential weighting'.

Forgetting factor - exponential weighting factor
0.9 (by default) | `positive scalar less than or equal to 1.0'.

The forgetting factor determines how much weight past data has had. With a forgetting coefficient of 0.9, old data has more weight than with a forgetting coefficient of 0.1. A forgetting rate of 1.0 means infinite memory - all previous samples have the same weight.

Dependencies

To enable this parameter, set the Method parameter to `Exponential weighting' and uncheck the Specify forgetting factor from input port parameter.

Algorithms

Sliding window method

In the sliding window method, the output for each input sample is the average of the current sample and of the previous samples, where is the length of the window in samples. To compute the first input sample, the algorithm waits until it has the number of input samples with a jump size. The jump size is defined as the difference of the window length and the slab length. The remaining samples in the window are considered zero. For example, if the window length is 5 and the overlap length is 2, the algorithm waits until it receives 3 input samples to calculate the first sample of the output signal. After generating the first output sample, it generates subsequent output samples for each number of input samples of jump size.

If no window length is specified, the algorithm chooses an infinite window length. In this mode, the output is the moving average of the current sample and all previous samples in the channel.

Exponential weighting method

In the exponential weighting method, the moving average is calculated recursively using the following formulae:

,

,

where

  • - is the moving average of the current sample.

  • - current sample of data input.

  • - moving average of the previous sample.

  • - forgetting rate.

  • - A weighting factor applied to the current data sample.

  • - the effect of previous data on the mean.

For the first sample, where , the algorithm selects . For the next sample, the weighting factor is updated and used to calculate the mean, according to the recursive equation. As the age of the data increases, the value of the weighting factor decreases exponentially and never reaches zero. In other words, recent data have a greater influence on the current mean than old data.

The forgetting coefficient determines how much weight past data had. With a forgetting coefficient of 0.9, old data has more weight than with a forgetting coefficient of 0.1. A forgetting rate of 1.0 means infinite memory - all previous samples have the same weight.