Recursive Least Squares Estimator

Estimate model coefficients using recursive least squares (RLS) algorithm

Library

Estimators

Description

Use the Recursive Least Squares Estimator block to estimate the parameters of a system that is linear in the parameters. Such a system has the following form:

y and H are known quantities that you provide to the block to estimate θ. The block estimates θ using the recursive least squares algorithm (see [1]).

For a given time step, t, y(t) and H(t) correspond to the Output and Regressors inports of the Recursive Least Squares Estimator block, respectively. θ(t) corresponds to the Parameters outport. y(t), must be a real-valued scalar. H and θ are real-valued vectors of length N, where N is the number of parameters to be estimated.

For example, suppose you want to estimate a scalar gain, θ, in the system y = h2θ. Here, y is linear with respect to θ. You can use the Recursive Least Squares Estimator block to estimate θ. Specify y and h2 as inputs to the Output and Regressor inports.

Dialog Box and Parameters

Model Parameters

Initial Estimate

Initial guess of the values of the parameters to be estimated, specified as one of the following options (each option can change the block dialog):

  •  None

  •  Internal

  •  External

Sample Time

Block sample time, specified as -1 or a positive scalar.

The default value is -1. The block inherits its sample time based on the context of the block within the model.

Algorithm and Block Options

Algorithm Options

Estimation Method

Recursive estimation algorithm, specified as one of the following (each option can change the block dialog):

  • Forgetting Factor — (Default) Forgetting factor algorithm

    If you select this option, you must specify the Forgetting Factor, λ, as a scalar in the (0 1] range. λ specifies the measurement window relevant for parameter estimation. Suppose the system remains approximately constant over T0 samples. You can choose λ such that:

    T0=11λ

    Setting λ = 1 corresponds to "no forgetting" and estimating constant coefficients. Setting λ < 1 implies that past measurements are less significant for parameter estimation and can be "forgotten." Set λ < 1 to estimate time-varying coefficients. Typical choices of λ are in the [0.98 0.995] range.

    The default value is 1.

  • Kalman Filter — Kalman filter algorithm

    If you select this option, you must specify the Noise Covariance Matrix as one of the following:

    • Real nonnegative scalar, α — Covariance matrix is an N-by-N diagonal matrix, with α as the diagonal elements.

    • Vector of real nonnegative scalars, [α1,...,αN] — Covariance matrix is an N-by-N diagonal matrix, with [α1,...,αN] as the diagonal elements.

    • N-by-N symmetric positive semi-definite matrix.

    N is the number of parameters to be estimated.

    0 values in the noise covariance matrix correspond to estimating constant coefficients. Values larger than 0 correspond to time-varying parameters. Large values correspond to rapidly changing parameters.

    The default value is 1.

  • Normalized Gradient — Normalized gradient adaptation algorithm

    If you select this option, you must specify the Adaptation Gain, γ, as a real, positive scalar. γ is directly proportional to the relative information content in the measurements. That is, when your measurements are trustworthy, specify a large value for γ, and vice versa.

    The default value is 1.

  • Gradient — Unnormalized gradient adaptation algorithm

    If you select this option, you must specify the Adaptation Gain, γ, as a real, positive scalar. γ is directly proportional to the relative information content in the measurements. That is, when your measurements are trustworthy, specify a large value for γ, and vice versa.

    The default value is 1.

For more information about these algorithms, see Recursive Algorithms for Online Estimation.

Block Options

Output estimation error

Add Error outport to the block. Use this signal to validate the estimation.

For a given time step, t, the estimation error is calculated as:

e(t)=y(t)yest(t).

On

Add Error outport.

Off

(Default) Do not add Error outport.

Output parameter covariance matrix

Add Covariance outport to the block. Use this signal to examine parameter estimation uncertainty.

This option is not available when Estimation Method is either Normalized Gradient or Gradient.

On

Add Covariance outport.

Off

(Default) Do not add Covariance outport.

Add enable port

Add Enable inport to the block. Use this input signal to specify a control signal that enables or disables parameter estimation. The block estimates the parameter values for each time step that parameter estimation is enabled. If you disable parameter estimation at a given step, t, then the software does not update the parameters for that time step. Instead, the block outputs the last estimated parameter values. Use this option, for example, to disable parameter estimation when the system enters a mode where the parameter values do not vary with time.

On

Add Enable inport.

Off

(Default) Do not add Enable inport.

External reset

Option to reset estimated parameters and parameter covariance matrix using specified initial values.

Suppose you reset the block at a time step, t. If the block is enabled at t, the software uses the initial parameter values specified in Initial Estimate to estimate the parameter values. In other words, at t, the block performs a parameter update using the initial estimate and the current values of the inports. The block outputs these updated parameter value estimates using the Parameters outport.

If the block is disabled at t and you reset the block, the block outputs the values specified in Initial Estimate.

Use this option, for example, when you reset the input because it did not excite the system as needed, resulting in poor estimation results.

Specify this option as one of the following:

  • None — (Default) Estimated parameters and covariance matrix values are not reset.

  • Rising — Triggers reset when the control signal rises from a negative or zero value to a positive value. If the initial value is negative, rising to zero triggers reset.

  • Falling — Triggers reset when the control signal falls from a positive or a zero value to a negative value. If the initial value is positive, falling to zero triggers reset.

  • Either — Triggers reset when the control signal is either rising or falling.

  • Level — Triggers reset in either of these cases:

    • Control signal is nonzero at the current time step

    • Control signal changes from nonzero at the previous time step to zero at the current time step

  • Level hold — Triggers reset when the control signal is nonzero at the current time step.

When you choose any option other than None, the software adds a Reset inport to the block. You provide the reset control input signal to this inport.

Ports

Port Name

Port Type

Description
RegressorsInH(t), specified as a real scalar or vector.
OutputIny(t), specified as a real scalar signal.
ParametersOutθ(t), returned as a vector of the same length as H(t).
Enable (Optional)InControl signal to enable parameter estimation, specified as a scalar.
Reset (Optional)InControl signal to reset parameter estimation, specified as a scalar.
InitialParameters (Optional)InInitial guess of the values of the parameters to be estimated, specified as a scalar or vector.
InitialCovariance (Optional)InInitial covariance of parameters, specified as a real positive scalar, vector of real positive scalars, or symmetric positive-definite matrix.
Error (Optional)OutEstimation error, returned as a scalar.
Covariance (Optional)OutCovariance of estimated parameters, returned as an N-by-N matrix. N is the number of parameters.

Supported Data Types

  • Double-precision floating point

  • Single-precision floating point

    Note:   The Regressors and Output inports must have matching data types.

References

[1] Ljung, L. System Identification: Theory for the User. Upper Saddle River, NJ: Prentice-Hall PTR, 1999, pp. 363–369.

Was this topic helpful?