Engee documentation

Moving RMS

The moving average is quadratic.

blockType: MovingRMS

Path in the library:

/Signal Operations/Statistics/Moving RMS

Description

Block Moving RMS calculates the moving average of the input signal for each channel regardless of time.

To calculate the moving average, the quadratic block uses either the sliding window method or the exponential weighting method.

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

In the exponential weighting method, the block squares the sequential values of the input signal, multiplies them by a set of weighting coefficients, and summarizes the weighted data. The block then calculates the quadratic mean by extracting the square root of the sum.

For more information about these methods, see Algorithms.

Ports

Input

# x — input data
vector | the matrix

Details

The block calculates the moving average of the quadratic value of the data indicated on the input port. The block accepts multi-channel input data of the following dimensions on , where and , with real or complex values.

If the check box is Allow arbitrary frame length for fixed-size input signals If the input signal is shown but not set, and the input signal has a fixed size, then 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 simulation process). When a variable-size signal is applied, the length of the signal frame can be arbitrary.

This port has no name yet for the parameter Method the value is not set Exponential weighting and the checkbox is not checked. Specify forgetting factor from input port.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128

Complex numbers support

Yes

# λ — the forgetting rate
scalar

Details

The forgetting coefficient, given as a positive real scalar of 0 before 1, determines how much weight the past data had. At the forgetting rate 0.9 old data has more weight than with the forgetting coefficient. 0.1. The forgetting rate 1.0 means infinite memory — all previous samples have the same weight.

Dependencies

To use this port, set the parameter Method meaning Exponential weighting and check the box Specify forgetting factor from input port.

Data types

Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32

Complex numbers support

No

Output

# OUT_1 — moving average output
vector | the matrix

Details

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

The table provides detailed information about the size of the output signal.

Input signal

Dimensions of the input signal

Dimensions of the output signal

The flag Allow arbitrary frame length for fixed-size input signals shown

The flag Allow arbitrary frame length for fixed-size input signals not shown

A fixed-size signal

on , where multiple of the jump size (window length is the length of the overlap)

(the size of the jump) on

on

A fixed-size signal

on , where not a multiple of the jump size (window length is the length of the overlap)

ceil( the size of the jump) on in case of a check box Allow arbitrary frame length for fixed-size input signals installed. If this checkbox is unchecked, the block returns an error.

on

A variable-size signal

on

ceil( the size of the jump) on

on

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

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128

Complex numbers support

Yes

Parameters

Main

# Method — the averaging method
Sliding window | Exponential weighting

Details
  • Sliding window — window length Window length moves through the input data along each channel. For each sample that the window moves through, the block calculates the quadratic average of the data in the window.

  • Exponential weighting — the block multiplies the samples by a set of weighting factors. The magnitude of the weights decreases exponentially as the age of the data increases, but the magnitude never reaches zero. To calculate the quadratic mean, the algorithm summarizes the weighted data.

Values

Sliding window | Exponential weighting

Default value

Sliding window

Program usage name

Method

Tunable

No

Evaluatable

No

# Specify window length — specify the window length
Logical

Details

If you select this option, the length of the sliding window will be equal to the value set for the parameter Window length. If you uncheck this option, the sliding window will be infinite in length. In this mode, the block calculates the mean square of the current sample and all previous samples in the channel.

Dependencies

To use this parameter, set for the parameter Method meaning Sliding window.

Default value

true (switched on)

Program usage name

SpecifyWindowLength

Tunable

No

Evaluatable

No

# Window length — sliding window length
Int64 integer

Details

Specifies the length of the sliding window in the selections.

Dependencies

To use this parameter, set for the parameter Method meaning Sliding window and check the box Specify window length.

Default value

4

Program usage name

WindowLength

Tunable

No

Evaluatable

Yes

# Overlap length — the length of the overlap between the windows
Int64 integer

Details

Specifies the length of the overlap between windows as a non-negative integer. The value of the overlap length varies from 0 before Window length − 1.

Dependencies

To use this parameter, set for the parameter Method meaning Sliding window and check the box Specify window length.

Default value

3

Program usage name

OverlapLength

Tunable

No

Evaluatable

Yes

# Allow arbitrary frame length for fixed-size input signals — allow arbitrary frame length for fixed-size input signals
Logical

Details

Specify whether fixed-size input signals (whose size does not change during simulation) can have an arbitrary frame length, where the frame length does not have to be a multiple of the jump size. The size of the jump is defined as the difference in the parameter values Window length and Overlap length. The block uses this parameter only for fixed-size input signals 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, that is, the frame length should not be a multiple of the jump size.

For fixed-size input signals:

  • If the check box is Allow arbitrary frame length for fixed-size input signals However, the length of the signal frame does not have to be a multiple of the jump size. If the input signal is not a multiple of the jump size, then the output is usually a variable-size signal. Therefore, to support an arbitrary input size, the block must also support variable-size operations, which can be enabled by checking the box. Allow arbitrary frame length for fixed-size input signals.

  • If the check box Allow arbitrary frame length for fixed-size input signals If the image is captured, then the length of the input frame must be a multiple of the jump size.

Dependencies

To use this parameter, set for the parameter Method meaning Sliding window and check the box Specify window length.

Default value

false (switched off)

Program usage name

AllowArbitrary

Tunable

No

Evaluatable

No

# Specify forgetting factor from input port — specify the forgetting rate via the input port
Logical

Details

When this option is selected, the forgetting coefficient is entered via the λ port. If you uncheck this box, the forgetting coefficient is set using the parameter Forgetting factor.

Dependencies

To use this parameter, set for the parameter Method meaning Exponential weighting.

Default value

false (switched off)

Program usage name

SpecifyForgettingFactorInput

Tunable

No

Evaluatable

No

# Forgetting factor — exponential weighting factor
Real number

Details

The forgetting coefficient determines how much weight the past data had. At the forgetting rate 0.9 old data has more weight than with the forgetting coefficient. 0.1. The forgetting rate 1.0 means infinite memory — all previous samples have the same weight.

Dependencies

To use this parameter, set for the parameter Method meaning Exponential weighting and uncheck the box Specify forgetting factor from input port.

Default value

0.9

Program usage name

ForgettingFactor

Tunable

No

Evaluatable

Yes

Algorithms

Sliding window method

Details

In the sliding window method, the output for each input sample is the quadratic average of the current sample and previous samples, where — this is the length of the window in samples. To calculate the first input sample, the algorithm waits until it gets the number of jump-sized input samples. The size of the jump is defined as the difference between the length of the window and the length of the overlap. The remaining samples in the window are considered null. For example, if the window length is 5, and the length of the overlap — 2, then the algorithm waits until it receives 3 input samples to calculate the first sample of the output signal. After generating the first output signal, it generates subsequent output samples for each number of jump-sized input samples.

If the window length is not specified, the algorithm selects 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

Details

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



where

  • — the quadratic moving average for the current sample;

  • — the square of the current data entry sample;

  • — the quadratic moving average of the previous sample;

  • — the coefficient of forgetting;

  • — the weighting factor applied to the current data sample;

  • — the effect of previous data on the quadratic mean.

For the first sample, where , the algorithm selects . For the next sample, the weighting factor is updated and used to calculate the quadratic 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, the latest data has a greater impact on the current value of the quadratic mean than the old ones.

The forgetting coefficient determines how much weight the past data had. At the forgetting rate 0.9 old data has more weight than with the forgetting coefficient. 0.1. The forgetting rate 1.0 means infinite memory — all previous samples have the same weight.