All problems
EM One M-Step Lite
Problem
Perform one lite EM M-step for the observation noise variance: r_new = mean((x - level)^2) + p, where p is the state covariance from the E-step.
Return p when observations is empty.
Hint
The state uncertainty p inflates the raw residual variance.
Test cases
case 1
in: [0,1,[1,2,3]]
expected: 5.666666666666667
case 2
in: [1,0,[1,1,1]]
expected: 0
case 3
in: [0,2,[]]
expected: 2
case 4
in: [2,0.5,[1,3]]
expected: 1.5
Starter codePython
def em_one_m_step(level, p, observations):
# Your code here
pass4 test cases · run your code against them in the editor