Engee documentation

Mean

The average value of the input data or sequence of input data.

blockType: Mean

Path in the library:

/Signal Operations/Statistics/Mean

Description

Block Mean Calculates the average value of each row, column, or vector of a given dimension of the input data. It can also calculate the average of the entire input signal. The dimension can be set using the parameter Find the mean value over. In addition, the block Mean can track the average value in a sequence of input signals over a certain period of time. To track the average value of a sequence of signal values, select the check box Running mean.

Ports

Output

# OUT_1 — the average value for the specified measurement
scalar | vector | the matrix | multidimensional array

Details

Calculated average value. The output data type is the same as the input data type.

If the check box is Running mean not set, the block calculates the average value in each row or column of the input data or across vectors of the specified dimension of the input data. It can also calculate the average value over the entire input at each individual moment of the sampling period. Each element of the output array — this is the average value of the corresponding column, row, or the entire input. Output array depends on the parameter setting Find the mean value over. Consider a three-dimensional input signal with the size on on . If set for the parameter Find the mean value over meaning:

  • Entire input — the output signal at each moment of the sampling period is a scalar containing the average value of the input array on on .

  • Each row — the output signal at each moment of the sampling period consists of an array on on , where each element contains the average value of each vector in the second dimension of the input. For the input matrix on The output signal at each moment of the sampling period is a column vector on .

  • Each column — the output signal at each moment of the sampling period consists of an array on on , where each element contains the average value of each vector in the first dimension of the input. For the input matrix on The output signal at each moment of the sampling period is a vector string on . In this mode, the block considers input undirected vectors of length as column vectors on .

  • Specified dimension — the output signal at each moment of the sampling period depends on the value of the parameter Dimension:

    • If for the parameter Dimension the value is set 1, the output signal will be the same as when selecting the value Each column for the parameter Find the mean value over.

    • If for the parameter Dimension set the value 2, the output signal will be the same as when selecting the value Each row.

    • If for the parameter Dimension set the value 3, then the output at each moment of the sampling period will be a matrix on , containing the average value of each vector in the third dimension of the input data.

If the check box is Running mean installed, the unit tracks the average value of each channel in a time sequence of inputs. In this mode, you must also specify the parameter value. Input processing:

  • Elements as channels (sample based) — the block treats each element of the input signal as a separate channel. For a three-dimensional input signal of the size on on the block outputs an array on on . Each element the output contains the average value of the element for all inputs since the last reset.

    When the reset event occurs, the moving average is in the current frame, it is reset to the element .

  • Columns as channels (frame based) — the block treats each input column as a separate channel. This option does not support -dimensional input signal, where . For a two-dimensional input signal of the size on the block outputs the matrix on . Each element The output signal contains the average of the values in -the m column of all inputs since the last reset, up to the element the current entrance, inclusive.

    When a reset event occurs, the moving average for each channel becomes equal to the average of all samples in the current input frame, up to and including the current input sample.

Data types

Float64

Complex numbers support

Yes

Input

# I — input data
scalar | vector | the matrix | multidimensional array

Details

The input signal, set as a multi-channel -dimensional data with real or complex values, where .

Dependencies

The name of this port is not displayed until the checkbox is selected. Running mean, and for the parameter Reset port a value other than None.

Data types

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

Complex numbers support

Yes

# Rst — reset port
scalar

Details

Specify the reset event at which the block resets the moving average value. The sampling period of the signal at the input port Rst must be a multiple of the sampling period of the input signal (the multiplier must be a positive integer).

Dependencies

To use this port, check the box Running mean and set for the parameter Reset port a value other than None.

Data types

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

Complex numbers support

No

Parameters

Main

# Running mean — activating moving average accounting
Logical

Details

Select this option so that the block tracks the average value for each channel in the time sequence of the input signals.

Default value

false (switched off)

Program usage name

run

Tunable

No

Evaluatable

No

# Find the mean value over — the measurement used by the block to calculate the average value
Entire input | Each row | Each column | Specified dimension

Details
  • Each column — the block outputs the average value for each column.

  • Each row — the block outputs the average value for each row.

  • Entire input — The unit outputs the average value of the entire input signal.

  • Specified dimension — the block outputs the average value of the dimension specified in the parameter Dimension.

Dependencies

To use this option, uncheck the box. Running mean.

Values

Entire input | Each row | Each column | Specified dimension

Default value

Each column

Program usage name

directionMode

Tunable

No

Evaluatable

No

# Dimension — dimension
Real number

Details

Specify the dimension (the dimension starts from one) of the input signal from which the block calculates the average value. The value of this parameter must be greater than zero and less than the number of measurements in the input signal.

Dependencies

To use this parameter, set for the parameter Find the mean value over meaning Specified dimension.

Default value

1

Program usage name

dimension

Tunable

No

Evaluatable

Yes

# Input processing — method of processing input data in execution mode
Columns as channels (frame based) | Elements as channels (sample based)

Details
  • Columns as channels (frame based) — the block treats each input column as a separate channel. This option does not support -dimensional input signal, where . For a two-dimensional input signal of the size on the block outputs a matrix on . Each element The output signal contains the average of the values in -the m column of all inputs since the last reset, up to the element the current entrance, inclusive.

    When a reset event occurs, the moving average for each channel becomes equal to the average of all samples in the current input frame, up to and including the current input sample.

  • Elements as channels (sample based) — the block treats each element of the input signal as a separate channel. For a three-dimensional input signal of the size on on the block outputs an array on on . Each element the output contains the average value of the element for all inputs since the last reset.

    When the reset event occurs, the moving average is in the current frame, it is reset to the element .

Dependencies

To use this option, check the box Running mean.

Values

Columns as channels (frame based) | Elements as channels (sample based)

Default value

Columns as channels (frame based)

Program usage name

InputProcessing

Tunable

No

Evaluatable

No

# Reset port — reset event
None | Rising edge | Falling edge | Either edge | Non-zero sample

Details

The block resets the moving average value when a reset event is detected on the Rst port. The sampling period of the reset signal must be a multiple of the sampling period of the input signal (the multiplier must be a positive integer).

If a reset event occurs when for the parameter Input processing the value is set Elements as channels (sample based), the moving average value for each channel is initialized with the value from the corresponding channel of the current input signal. Similarly, if for the parameter Input processing the value is set Columns as channels (frame based), the moving average value for each channel becomes equal to the average value of all samples in the current input frame, up to and including the current input sample.

Use this parameter to set the reset event.:

  • None — disables the Rst port.

  • Rising edge — initiates a reset operation when the signal on the input port is Rst:

    • Increases from a negative value to a positive value or zero.

    • Increases from zero to a positive value, provided that this growth is not a continuation of the growth from a negative value to zero.

      mean 5 en

  • Falling edge — initiates a reset operation when the signal on the input port is Rst:

    • Decreases from a positive value to a negative value or zero.

    • Decreases from zero to a negative value, provided that this decrease is not a continuation of the decline from a positive value to zero.

      mean 6 en

  • Either edge — initiates a reset operation if there are values on the input port Rst Rising edge or Falling edge.

  • Non-zero sample — initiates a reset operation at each moment of the sampling period when the signal on the input port Rst is nonzero.

Dependencies

To use this option, check the box Running mean.

Values

None | Rising edge | Falling edge | Either edge | Non-zero sample

Default value

None

Program usage name

reset_popup

Tunable

No

Evaluatable

No

Algorithms

Average value

Details

If the check box Running mean removed and the dimension specified, the block produces results identical to the next function call mean:

y = mean(u, D)

Where

  • — input data;

  • — dimension;

  • — average value.

The average value over the entire input data array corresponds to a function call mean in the form of

y = mean(u[:])

For complex input data, the average value is calculated independently for the real and imaginary components.

mean 2 en

Moving average

Details

If the check box Running mean set, and for the parameter Input processing the value is set Columns as channels (frame based) The block treats each column of input data as a separate channel. In the example in the figure below, with such settings, the unit processes a two-channel signal with a frame size of three.

mean 3 en

The block displays the average value for each channel calculated since the last reset. At a point in time a reset event occurs. Now the data window in the second column contains only the value 6.

If the check box Running mean set, and for the parameter Input processing the value is set Elements as channels (sample based) The block treats each element of the input data as a separate channel. In the example in the figure below, with such settings, the unit processes a two-channel signal with a frame size of three.

mean 4 en

Each element The output signal contains the average value obtained for the element for all input data since the last reset. The reset event occurs at a point in time . When the reset event occurs, the moving average in the current frame, it takes the value of the element .

Additional options

C code generation: Yes