Engee documentation

LMS Filter

Adaptive least-mean-squares algorithm for calculating outputs, errors, and weights.

blockType: LMSFilter

Path in the library:

/Signal Operations/Filters/Adaptive Filters/LMS Filter

Description

Block LMS Filter It can implement an adaptive FIR filter using five different algorithms. The block evaluates the filter weights needed to minimize the error. between the output signal and the desired signal . The output is a filtered input signal, which is an estimate of the desired signal. The Error port outputs the result of subtracting the output signal from the desired signal.

Ports

Input

# Input — The input signal
scalar | column vector

Details

The input signal is specified as a scalar or column vector.

If for the parameter Algorithm the value is set Sign-Error LMS, Sign-Data LMS or Sign-Sign LMS, then the data on the Input port must be real.

Data types

Float32, Float64

Complex numbers support

No

# Desired — the desired signal
scalar | column vector

Details

The desired signal, specified as a scalar or column vector.

The desired signal must have the same data type, complexity, and size as the signal on the Input port.

If for the parameter Algorithm the value is set Sign-Error LMS, Sign-Data LMS or Sign-Sign LMS, then the data on the Desired port must be real.

Data types

Float32, Float64

Complex numbers support

No

# Adapt — updating the filter weights
scalar

Details

If the value on the Adapt port is greater than zero, the block constantly updates the filter weights.

If the value on the Adapt port is less than or equal to zero, the weights remain at their current values.

Dependencies

To use this port, check the box Adapt port.

Data types

Float32, Float64, Int8, Int16, Int32, Bool

Complex numbers support

No

# Reset — resetting the filter weights
scalar

Details

A signal for resetting the values of the filter weights to their initial values, set as a scalar.

The block resets the weights each time a reset event is detected on the Reset port.

For the types of reset events, see the parameter Reset port.

Dependencies

To use this port, set the parameter Reset port meaning Rising edge, Falling edge, Either edge or Non-zero sample.

Data types

Float32, Float64, Int8, Int16, Int32, Bool

Complex numbers support

No

# Step-size — step size
scalar

Details

Enter the step size .

For convergence of the algorithm equations Normalized LMS: .

The input data type must match the data type on the Input port.

Dependencies

To use this port, set the parameter Specify step size via meaning Input port.

Data types

Float32, Float64

Complex numbers support

No

Output

# Output — evaluation of the desired signal
scalar | column vector

Details

The estimate of the desired signal, returned as a scalar or column vector. It has the same size and complexity as the input signal.

The output signal has the same data type as the desired signal.

Data types

Float32, Float64

Complex numbers support

No

# Error — error between output and desired signals
scalar | column vector

Details

The error between the output and desired signals, returned as a scalar or column vector. This error is the result of subtracting the output signal from the desired signal.

The error signal has the same data type as the desired signal.

Data types

Float32, Float64

Complex numbers support

No

# Wts — filter weights
scalar | column vector

Details

The filter weights returned as a scalar or column vector. For each iteration, the block outputs the current updated filter weights from this port.

Dependencies

To use this port, check the box Output filter weights.

Data types

Float32, Float64

Complex numbers support

No

Parameters

Main

# Algorithm — algorithm for calculating filter weights
LMS | Normalized LMS | Sign-Error LMS | Sign-Data LMS | Sign-Sign LMS

Details

Select the algorithm used to calculate the filter weights.

Values

LMS | Normalized LMS | Sign-Error LMS | Sign-Data LMS | Sign-Sign LMS

Default value

LMS

Program usage name

Algorithm

Tunable

No

Evaluatable

No

# Filter length — filter length
Int64 integer

Details

Enter the length of the FIR filter weight vector.

Default value

32

Program usage name

FilterLength

Tunable

No

Evaluatable

Yes

# Specify step size via — the step size setting method
Dialog | Input port

Details
  • Dialog — specify the step size using the parameter Step size (mu).

  • Input port — specify the step size using the Step-size port.

Values

Dialog | Input port

Default value

Dialog

Program usage name

SpecifyStepSizeVia

Tunable

No

Evaluatable

No

# Step size (mu) — step size
Real number

Details

Enter the step size .

For convergence of the algorithm equations Normalized LMS: .

Dependencies

To use this parameter, set for the parameter Specify step size via meaning Dialog.

Default value

0.1

Program usage name

StepSize

Tunable

Yes

Evaluatable

Yes

# Leakage factor (0 to 1) — loss ratio
Real number

Details

Enter the loss factor .

Default value

1.0

Program usage name

LeakageFactor

Tunable

Yes

Evaluatable

Yes

# Initial value of filter weights — the initial value of the filter weights
Scalar / vector of real and/or complex numbers

Details

Enter the initial value of the filter weights in the form of a vector or scalar.

If you enter a scalar, the block uses the scalar value to create a vector of filter weights. The length of this vector is equal to the length of the filter, and all its values are equal to a scalar value.

Default value

0.0

Program usage name

InitialValueOfFilterWeights

Tunable

No

Evaluatable

Yes

# Adapt port — enable the adaptation port
Logical

Details

Select this option to enable the Adapt port.

Default value

false (switched off)

Program usage name

AdaptPort

Tunable

No

Evaluatable

No

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

Details

If you want to reset the filter weights to their initial values, use this parameter.

The reset signal must have the same speed as the input data signal.

  • None — disable the Reset port.

To enable the Reset port, select one of the following values:

  • Rising edge — starts a counting or reset operation when the signal on the input port Reset changes as follows:

    • Increases from the leading edge to positive or zero;

    • Increases from zero to the leading edge when the increase is not a continuation of the increase from the trailing edge to zero, as shown in the figure:

      counter 1

  • Falling edge — starts a counting or reset operation when the signal on the input port Reset changes as follows:

    • Decreases from the leading edge to negative or to zero;

    • Decreases from zero to the trailing edge when the decrease is not a continuation of the decrease from the leading edge to zero, as shown in the figure:

      counter 2

  • Either edge — starts a counting or reset operation when a trigger event occurs on the input port Reset Rising edge or Falling edge.

  • Non-zero sample — starts the counting or reset operation at each sampling clock cycle when the signal on the input port Reset is not zero.

Values

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

Default value

None

Program usage name

ResetPort

Tunable

No

Evaluatable

No

# Output filter weights — weighting factors at the filter output
Logical

Details

Select this option to export the filter weights from the Wts output port. For each iteration, the block outputs the current updated weights from this port.

Default value

true (switched on)

Program usage name

OutputFilterWeights

Tunable

No

Evaluatable

No

Additional Info

LMS Filter Algorithms

Details

If for the parameter Algorithm the value is set LMS The block calculates the filter weights using the Least Mean Squares (LMS) algorithm. This algorithm is defined by the following equations:





The various adaptive LMS filter algorithms available in this block are defined as follows:

  • LMS:

  • Normalized LMS:

    In the case Normalized LMS to overcome the potential numerical instability when updating the weights, a small positive constant is added to the denominator . For double-precision floating-point inputs equals the output of the function eps(Float64). For single precision data equals the output of the function eps(Float32).

  • Sign-Error LMS:

  • Sign-Data LMS:

    where is a real number.

  • Sign-Sign LMS:

    where is a real number.

The following variables are used in the equations above:

  • — current time index;

  • — a vector of buffered input samples per step ;

  • is a complex conjugate vector of buffered input samples per step ;

  • — the vector of weight estimates of the filter in the step ;

  • — filtered output signal in the step ;

  • — estimation error in the step ;

  • — the desired signal in the step ;

  • — the size of the adaptation step;

  • — the loss coefficient is such that ;

  • — a constant that corrects for any potential numerical instability that occurs during the update of the weights.

Literature

  1. Hayes, M.H. Statistical Digital Signal Processing and Modeling. New York: John Wiley & Sons, 1996.