Apply the soft-thresholding operator used by one coordinate-descent step of the lasso: shrink the value z toward zero by lam, and set it to exactly zero if ∣z∣≤λ.
Implement solve(z,lam).
Returns. Return the shrunken value as a float (0.0 when it is thresholded away). lam must be non-negative.
Example 1
Input:
solve(3.0, 1.0)
Output:
2.0
Example 2
Input:
solve(-2.5, 1.0)
Output:
-1.5
Example 3
Input:
solve(0.4, 1.0)
Output:
0.0
No results yet
Run your code to check it against the examples, or submit to run every test.