A MATLAB/Octave toolbox for recursive parameter estimation and system identification. This repository implements various least squares estimation methods, from basic to advanced recursive algorithms with exponential forgetting.
- Basic Least Squares Estimation (MMQ)
- Weighted Least Squares (MMQP)
- Recursive Least Squares (MMQR)
- Recursive Least Squares with Exponential Forgetting (MMQRE)
- Built-in validation and regression tools
- Suitable for real-time parameter estimation
- Compatible with both MATLAB and Octave
The basic least squares estimator.
[Theta] = MMQ(PHI, Y)PHI: Regressor matrixY: Output vector- Returns: Estimated parameters
Theta
A weighted version of the least squares estimator.
[Theta] = MMQP(PHI, Y)PHI: Regressor matrixY: Output vector- Returns: Estimated parameters
Theta - Features: Implements a weighting scheme (0.6) for datasets with less than 60 samples
A recursive least squares estimator.
[THETA, Pk] = MMQR(P, Phi, Theta, y)P: Covariance matrixPhi: Current regressor vectorTheta: Current parameter estimatey: Current output measurement- Returns:
- Updated parameters
THETA - Updated covariance matrix
Pk
- Updated parameters
An extended version of MMQR with exponential forgetting factor.
[THETA, Pk] = MMQRE(P, Phi, Theta, y, L)P: Covariance matrixPhi: Current regressor vectorTheta: Current parameter estimatey: Current output measurementL: Forgetting factor (lambda)- Returns:
- Updated parameters
THETA - Updated covariance matrix
Pk
- Updated parameters
% Example data
PHI = [1 2; 3 4; 5 6]; % Regressor matrix
Y = [1; 2; 3]; % Output vector
% Estimate parameters
Theta = MMQ(PHI, Y);% Initial setup
P = eye(2); % Initial covariance matrix
Theta = zeros(2,1); % Initial parameter estimate
% For each new measurement
for k = 1:N
phi = [x1(k); x2(k)]; % Current regressor vector
y = y(k); % Current measurement
% Update parameters
[Theta, P] = MMQR(P, phi, Theta, y);
end% Initial setup
P = eye(2); % Initial covariance matrix
Theta = zeros(2,1); % Initial parameter estimate
lambda = 0.95; % Forgetting factor
% For each new measurement
for k = 1:N
phi = [x1(k); x2(k)]; % Current regressor vector
y = y(k); % Current measurement
% Update parameters with forgetting
[Theta, P] = MMQRE(P, phi, Theta, y, lambda);
end- The MMQP function automatically applies a weighting factor of 0.6 for datasets with less than 60 samples
- For MMQRE, the choice of the forgetting factor (lambda) is important and should be tuned based on:
- Data velocity
- Amount of data
- System dynamics
- Typical values for lambda range between 0.95 and 0.99
- Henrique Perez Gomes da Silva
- hperez@unifei.edu.br
- Maid with ❤️ in UNIFEI - Federal de Itajubá :)
- Tnx to Prof. Jeremias B. Machado