LMS Filter
Adaptive least mean squares (LMS) algorithm to compute outputs, errors and weights.
Description
The LMS Filter block can implement an adaptive FIR filter using five different algorithms. The block estimates the filter weights required to minimise the error, , between the output signal, , and the desired signal, . The output is the 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 - input signal
scalar
| vector-column
Input signal specified as a scalar or column vector.
If Algorithm is set to Sign-Error LMS
, Sign-Data LMS
or Sign-Sign-Sign LMS
, the data on the Input port must be real.
-
Data types:*
single
|Float64
.
Desired - desired signal
scalar
| vector-column
Desired signal specified as a scalar or vector-column.
The desired signal must have the same data type, complexity and dimensions as the signal on the Input port.
If Algorithm is set to Sign-Error LMS
, Sign-Data LMS
or Sign-Sign-Sign LMS
, the data on the Desired port must be real.
-
Data types:*
single
|Float64
.
Step-size - step-size
scalar
Enter the step size, .
For convergence of the equations of the Normalised LMS algorithm: .
The input data type must match the data type of the Input input.
Dependencies
This port only appears if the Specify step size via parameter is set to Input port
.
-
Data types:*
single
|Float64
Adapt - update filter weights
scalar
If the value on the Adapt port is greater than zero, the block constantly updates the filter weight coefficients.
If the value on the Adapt port is less than or equal to zero, the weight coefficients remain at their current values.
Dependencies
This port appears only if the Adapt port parameter is set to on
.
-
Data types:*
single
|Float64
|Int8
|Int16
|Int32
|Boolean
Reset - reset filter weights
scalar
Signal for resetting the values of filter weight coefficients to their initial values set as a scalar.
The block resets the weight coefficient values each time a reset event is detected on the Reset port.
See Reset port parameter for reset event types.
Dependencies
This port appears only when the Reset port parameter is set to Rising edge
, Falling edge
, Either edge
or Non-zero sample
.
-
Data types:*
single
|Float64
|Int8
|Int16
|Int32
|Boolean
Output
Output - evaluation of the desired signal
scalar
| vector-column
An estimate of the desired signal returned as a scalar or vector-column. 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:*
single
|Float64
.
Error - error between output and desired signals
scalar
| vector-column
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:*
single
|Float64
Wts - filter weights
scalar
| vector-column
Filter weight coefficients returned as scalar or vector-columns. For each iteration, the block outputs the current updated filter weights from this port.
Dependencies
This port appears only if the Output filter weights parameter is set to On
.
-
Data types:*
single
|Float64
Parameters
Main
Algorithm - algorithm for calculating filter weights
LMS (by default)
| Normalised LMS
| Sign-Error LMS
| Sign-Data LMS
| Sign-Sign LMS
Select the algorithm used to calculate the filter weights.
Filter length - filter length
32 (By default)
| scalar
Enter the length of the FIR filter weights vector.
Specify step size via - method of step size specification
Dialog (by default)
| Input port
.
-
Dialog
- specify step size using Step size (mu) parameter. -
Input port
- specify step size using Step-size port.
Step size (mu) - step size
0.1 (by default)
| positive scalar
Enter the step size, .
For convergence of the equations of the Normalised LMS algorithm : .
Dependencies
This parameter appears only if the Specify step size via parameter is set to Dialog
.
Leakage factor (0 to 1) - loss factor
1.0 (By default)
| scalar
.
Enter the loss factor, .
Initial value of filter weights - initial value of filter weights
0 (by default)
| vector
| scalar
Enter the initial value of filter weights w(0) as vector or scalar.
If you enter a scalar, the block uses the scalar value to create a vector of filter weight coefficients. The length of this vector is equal to the length of the filter, and all of its values are equal to the scalar value.
Adapt port - enable adapt port
Disabled (by default)
| On
Select this check box to enable the Adapt port.
Reset port - reset port
None (by default)
| Rising edge
| Falling edge
| Either edge
| Non-zero sample
.
If you want to reset the filter weights to their initial values, use the Reset port 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 from the list:
-
Rising edge
- starts a count or reset operation when the signal on the Inc/Dec or Rst input ports changes as follows:-
Rises from rising edge to positive or zero.
-
Rises from zero to rising edge when the rise is not a continuation of the rise from trailing edge to zero as shown.
-
-
Falling edge
- Starts a count or reset operation when the signal at the Inc/Dec or Rst input ports changes as follows:-
Decreases from the rising edge to negative or 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.
-
-
Either edge
- starts a count or reset operation when aRising edge
orFalling edge
start event occurs on the Inc/Dec or Rst input ports. -
Non-zero sample
- starts a count or reset operation at each sample clock when the signal at the Inc/Dec or Rst input ports is not zero.
Output filter weights - filter output weights
On (By default)
| Off
.
Select the Output filter weights parameter to export filter weights from the Wts output port. For each iteration, the block outputs the current updated weights from this port.
Optional
*Algorithms of LMS-filter
When you select LMS
for the Algorithm parameter, the block calculates the filter weights using the least mean square (LMS) algorithm. This algorithm is defined by the following equations.
The different adaptive LMS filter algorithms available in this block are defined as:
-
LMS -
-
Normalized LMS -
In the normalised LMS, to overcome the potential numerical instability in updating the weights, a small positive constant is added to the denominator .
For double precision floating point input data, equals the output of the eps(Float64)
function. For single-precision data equals the output of the eps(Float32)
function.
-
Sign-Error LMS -
-
Sign-Data LMS -
where u(n) is a real number.
-
Sign-Sign LMS -
where u(n) is real.
Variable | Description |
---|---|
|
Index of the current time |
u`( ) |
Vector of buffered input samples per step |
u`( ) |
Complex conjugate vector of buffered input samples per step |
w`( ) |
Vector of filter weight estimates at step |
|
Filtered output signal at step |
|
Estimation error at step |
|
Desired signal at a step |
|
Adaptation step size |
|
Loss factor ( ) |
|
A constant that corrects for any potential numerical instability that occurs during the update of the weights. |