Kalman Filter & Fault Detection

Kalman Filter & Fault Detection

View Github repo

Click here for live demo
View Github repo

Click to view Notebook

Overview

This project implements a complete discrete-time Kalman filter for state estimation and a residual-based fault detection system using statistical hypothesis testing. The system is modeled as a double integrator (position and velocity), subject to Gaussian process and measurement noise. The Kalman filter reconstructs unmeasured states from noisy measurements, while the innovation (residual) sequence is analyzed to detect sensor faults.

The notebook demonstrates core principles of robust and fault-tolerant control, including state-space modeling, covariance propagation, innovation-based diagnostics, and chi-squared statistical testing. Detection performance is quantified using Normalized Innovation Squared (NIS) and Receiver Operating Characteristic (ROC) analysis. The project highlights how model-based estimation and statistical decision theory form the foundation of modern fault detection and robust control systems.

The Jupyter Notebook combines mathematical derivations with executable simulations and visual analysis.

System Modeling

  • Discrete-time state-space representation

  • Double integrator dynamics

  • Process noise covariance (Q)

  • Measurement noise variance (R)

Kalman Filter Outputs

  • True vs noisy measurements

  • True vs estimated position and velocity

  • Residual (innovation) sequence

  • Innovation covariance tracking

  • RMSE metrics for estimation accuracy

Fault Detection Analysis

  • Residual comparison (healthy vs faulty case)

  • Normalized Innovation Squared (NIS) values

  • Chi-squared detection threshold

  • Detection rate statistics

Performance Evaluation

  • ROC curve

  • Area Under Curve (AUC) metric

All equations are rendered in LaTeX alongside implementation code, and the notebook renders natively on GitHub.


Key Engineering Concepts

State-Space Modeling

​​

  • Linear discrete-time system

  • Gaussian process noise wk∼N(0,Q)

  • Gaussian measurement noise vk∼N(0,R)

Kalman Filter (Predict–Update)

Predict:

Update:

  • Covariance propagation

  • Innovation sequence rk=yk−Cx^k∣k−1

Fault Detection (NIS)

  • Chi-squared hypothesis testing

  • Statistical thresholding (99% confidence)

  • Model-based fault detection

ROC Analysis

  • False Positive Rate (FPR)

  • True Positive Rate (TPR)

  • Area Under Curve (AUC)

Quantifies discrimination between healthy and faulty conditions.

Example Scenarios / Validation

1. Healthy System Estimation

The Kalman filter closely tracks true position and velocity despite noisy measurements. RMSE remains low, validating estimator accuracy.

2. Sensor Bias Fault Injection

A 3 m measurement bias introduced at k = 100 causes residuals to spike and NIS values to exceed the chi-squared threshold.

3. Detection Rate Analysis

Post-fault samples show high exceedance of threshold, yielding detection rates typically above 90% in nominal scenarios.

4. ROC-Based Evaluation

ROC curve visualizes detection performance. AUC quantifies separability between healthy and faulty cases.

5. Noise Sensitivity

Higher measurement noise increases residual variance and may reduce detection reliability — illustrating robustness trade-offs.


Tech Stack

Python, Jupyter Notebook, NumPy, SciPy, Matplotlib, Scikit-learn (ROC/AUC), GitHub native notebook rendering.

View the Notebook

Open Kalman Fault Detection Notebook

Create a free website with Framer, the website builder loved by startups, designers and agencies.