All problems
Stochastic Approximation Step
Problem
Take one stochastic approximation step with a decreasing gain.
Return x - (a / (k + b)) * grad, where k is the iteration index.
Hint
The gain a / (k + b) must shrink over iterations for convergence.
Test cases
case 1
in: [1,2,0.5,1,0]
expected: 0
case 2
in: [1,2,0.5,1,4]
expected: 0.8
case 3
in: [0,-1,1,2,3]
expected: 0.2
case 4
in: [2,0,0.1,1,9]
expected: 2
Starter codePython
def stochastic_approximation_step(x, grad, a, b, k):
# Your code here
pass4 test cases · run your code against them in the editor