Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-046

Kalman Gain

Problem

Compute the Kalman gain for a one-dimensional state with prior variance p and observation noise variance r: K = p / (p + r).

Return 0.0 when the denominator is zero.

Hint

The gain is close to 1 when the prior is uncertain relative to the noise.

Test cases

case 1
in: [1,1]
expected: 0.5
case 2
in: [2,1]
expected: 0.6666666666666666
case 3
in: [0,5]
expected: 0
case 4
in: [3,0]
expected: 1
Starter codePython
def kalman_gain(p, r):
    # Your code here
    pass

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