def ProximityOperator(kappa, a):
        """
        The soft thresholding operator, used to enforce L1 regularization. It produces the solution to: 
        \argmin_x 2 \kappa | x | + (x - a)^2 
        """
        if a > kappa: return a - kappa
        elif a < -kappa: return a + kappa
        else: return 0.