Learning and estimation of dynamical systems assignment
This project, developed by Gabriele Ruscelli for the LEDS Exam on July 25, 2023, consists of two main exercises:
- System Identification: Estimating an unknown linear model from provided signals.
- Classification: Creating a classifier to categorize data into distinct classes.
The project is implemented in MATLAB and includes detailed steps for model estimation, validation, and classification. Below is a breakdown of the two exercises and their respective components.
The goal of this exercise is to estimate an unknown linear model from provided signals. The signals could correspond to either an ARX (AutoRegressive with eXogenous input) model or a FIR (Finite Impulse Response) model. The task involves:
- Identifying the model structure (ARX or FIR).
- Estimating the model parameters using the Least Squares (LS) method.
- Validating the model using statistical tests and cross-validation.
-
Data Collection:
- A training set and a validation set are generated using the
IdentifyThisfunction. - Input (
u) and output (y) signals are collected for both sets.
- A training set and a validation set are generated using the
-
Model Structure Analysis:
- FIR Model: A static model where the output at time
tdepends only on the input. - ARX Model: A dynamic model where the output at time
tdepends on both past outputs and inputs. - The autocorrelation of the input signal is analyzed to ensure it is suitable for estimation.
- FIR Model: A static model where the output at time
-
Model Order Estimation:
- The Minimum Description Length (MDL) criterion is used to determine the optimal model order for both FIR and ARX models.
- The model order is selected based on the MDL function's behavior.
-
Model Estimation:
- The Least Squares method is applied to estimate the coefficients of the FIR and ARX models.
- The estimated coefficients are displayed.
-
Model Validation:
- Residuals are computed and analyzed to check if they resemble white noise.
- Statistical tests (e.g., Anderson test, chi-square test) are performed to validate the model.
- Cross-validation is used to assess the model's predictive performance.
-
Conclusion:
- An F-test is used to compare the FIR and ARX models, concluding that the FIR model is more suitable for the given data.
The goal of this exercise is to create a classifier that can categorize data into distinct classes based on a training set and then test its performance on a separate test set. The classifier is built using Linear Discriminant Analysis (LDA).
-
Data Collection:
- A training set (
Utrain,Ytrain) and a test set (Utest,Ytest) are generated using theClassifyThosefunction. - The training set is divided into three classes (
C1,C2,C3).
- A training set (
-
Data Visualization:
- The training data is plotted to visualize the distribution of the three classes in 2D space.
-
Linear Discriminant Analysis (LDA):
- The mean and covariance matrices for each class are computed.
- A common covariance matrix is calculated and used to define the decision boundaries.
- The posterior probabilities for each class are estimated using the Gaussian distribution.
-
Classification:
- The classifier assigns each data point in the test set to one of the three classes based on the highest posterior probability.
- Misclassified points are counted and their percentage is calculated.
-
Results:
- The classified test set is plotted along with the decision boundaries.
- The number of misclassified points is displayed, showing that the classifier performs well with a low error rate.
The project uses several custom MATLAB functions, including:
IdentifyThis: Generates the training and validation datasets for system identification.LS: Implements the Least Squares method for model estimation.MDL: Computes the Minimum Description Length criterion for model order selection.Cost_function: Evaluates the cost function for model validation.Anderson_test: Performs the Anderson whiteness test on residuals.ClassifyThose: Generates the training and test datasets for classification.- Various plotting functions to visualize data and results.
- Clone the repository and ensure all MATLAB files are in the same directory.
- Open the
Surname_Name.mlxfile in MATLAB. - Run the code section by section to visualize the results and understand the process.
- Modify parameters (e.g., model order, test set size) to explore different scenarios.
This project demonstrates a comprehensive approach to system identification and classification using MATLAB. The system identification exercise successfully estimates and validates a FIR model, while the classification exercise builds an effective classifier using Linear Discriminant Analysis. The code is well-documented and can be easily extended for similar tasks.
For any questions or feedback, feel free to contact Gabriele Ruscelli.
Note: Ensure that the Functions folder is added to the MATLAB path for the code to run correctly.