1. Generates a noisy quadratic signal 2. Applies a Kalman filter to estimate the true signal 3. Visualizes the results with 3 lines: Blue: The noisy signal Red: The Kalman filter estimate Green (dashed): The true quadratic signalThe Kalman filter parameters are tuned for this specific case: 1. Uses a 3rd order model (position, velocity, acceleration) 2. The measurement noise R is set to 50 3. Process noise Q is set to 0.1 on the diagonal 4. Initial uncertainty P0 is set high (1000) to give more weight to measurements initially
_
Press enter or click to view image in full size
_
import numpy as np import matplotlib.pyplot as plt
# Generate noisy data np.random.seed(0) # For reproducibility mu, sigma = 0, 500 x = np.arange(1, 100, 0.1) z = np.random.normal(mu, sigma, len(x)) y = x ** 2 + z # Noisy quadratic signal