Lesson 15 of 15
Kalman Filter (1D)
Kalman Filter (1D)
The Kalman filter is an optimal recursive estimator for linear systems with Gaussian noise. In 1D, it tracks a hidden state from noisy observations.
State space model
State: x[t] = x[t-1] + noise_q (process noise variance q)
Observation: z[t] = x[t] + noise_r (observation noise variance r)
One-step update
Given current estimate x_est with uncertainty p_est:
Predict:
x_pred = x_est
p_pred = p_est + q
Update (using observation z):
K = p_pred / (p_pred + r) (Kalman gain)
x_new = x_pred + K * (z - x_pred) (updated estimate)
p_new = (1 - K) * p_pred (updated uncertainty)
Task
Implement:
kalman_update(x_est, p_est, z, q, r_noise)→ returns (x_new, p_new)kalman_filter(observations, q, r_noise, x0, p0)→ list of filtered state estimates
Python runtime loading...
Loading...
Click "Run" to execute your code.