def soft_thresholding(v, threshold):
    """
    soft thresholding function
    :param v: scalar
    :param threshold: positive scalar
    :return: st(v)

    """

    if v >= threshold:
        return (v - threshold)
    elif v <= - threshold:
        return (v + threshold)
    else:
        return 0