Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-364

Kalman Track Update

Problem

Run the scalar Kalman measurement update for a tracked coordinate.

With prior mean x and variance p, measurement z and measurement noise r, the gain is K = p / (p + r); the updated mean is x + K * (z - x) and the updated variance is (1 - K) * p. Return [mean, variance] rounded to 4 decimal places.

Hint

A large measurement noise r drives the gain toward zero and trusts the prior.

Test cases

case 1
in: [0,1,2,1]
expected: [1,0.5]
case 2
in: [5,4,5,0]
expected: [5,0]
case 3
in: [2,3,4,9]
expected: [2.5,2.25]
case 4
in: [0,0,1,1]
expected: [0,0]
Starter codePython
def kalman_update(x, p, z, r):
    # Your code here
    pass

4 test cases · run your code against them in the editor