All problems
Kalman Smoother Variance
Problem
Perform the variance recursion of the Rauch-Tung-Striebel smoother. Given the filtered variance p_filtered, the predicted variance p_predicted, and the smoothed variance at the next time step p_smoothed_next, return p_filtered + J^2 * (p_smoothed_next - p_predicted) where J = p_filtered / p_predicted.
If p_predicted is zero, return p_filtered unchanged.
Hint
The weight J shrinks the future variance correction onto the filtered state.
Test cases
case 1
in: [1,2,1.5]
expected: 0.875
case 2
in: [0.5,1,0.4]
expected: 0.35
case 3
in: [2,2,2]
expected: 2
case 4
in: [1,0,3]
expected: 1
case 5
in: [0.5,2,0.5]
expected: 0.40625
Starter codePython
def kalman_smoother_variance(p_filtered, p_predicted, p_smoothed_next):
# Your code here
pass5 test cases · run your code against them in the editor