All problems
Kalman Likelihood 1D
Problem
Compute the Gaussian log likelihood of a one-dimensional Kalman filter innovation: -0.5 * (ln(2*pi) + ln(p + r) + innovation^2 / (p + r)), where innovation = obs - prior.
Return 0.0 if p + r is not positive.
Hint
The innovation variance is prior variance plus observation noise variance.
Test cases
case 1
in: [0,1,0,1]
expected: -1.2655121234846454
case 2
in: [0,1,2,1]
expected: -2.2655121234846454
case 3
in: [5,2,5,3]
expected: -1.723657489421723
case 4
in: [0,0,3,1]
expected: -5.418938533204672
Starter codePython
import math
def kalman_likelihood_1d(prior, p, obs, r):
# Your code here
pass4 test cases · run your code against them in the editor