All problems
Proximal Operator of L1 Vector
Problem
The proximal operator of t * ||v||_1 is the soft threshold sign(v) * max(|v| - t, 0) applied coordinatewise.
Given the vector and threshold t, return the prox.
Hint
Shrink every coordinate toward zero by t, flooring at zero.
Test cases
case 1
in: [[1,-2,0.1],0.5]
expected: [0.5,-1.5,0]
case 2
in: [[3,-4],1]
expected: [2,-3]
case 3
in: [[2,2],2]
expected: [0,0]
Starter codePython
def proximal_operator_l1_vector(v, t):
# Your code here
pass3 test cases · run your code against them in the editor