All problems
LM Damping Update
Problem
Adjust the Levenberg-Marquardt damping parameter after a trial step.
If ratio < 0.25 multiply lam by grow; if ratio > 0.75 multiply lam by shrink; otherwise keep lam unchanged. Return [lam_new, accepted] where accepted is the boolean ratio > 0.0.
Hint
Poor steps increase damping; very good steps decrease it.
Test cases
case 1
in: [1,0.1,2,0.5]
expected: [2,true]
case 2
in: [1,0.9,2,0.5]
expected: [0.5,true]
case 3
in: [1,0.5,2,0.5]
expected: [1,true]
case 4
in: [4,-0.2,10,0.1]
expected: [40,false]
Starter codePython
def lm_damping_update(lam, ratio, grow, shrink):
# Returns [lam_new, accepted]
# Your code here
pass4 test cases · run your code against them in the editor