def mcp_eval_1d(x, pen_val, a=2):
    """
    Evaluates the MCP penalty funciton at |x|.

    Parameters
    ----------
    x: float

    pen_val: float

    a: float

    Output
    ------
    value: float
    """
    # https://statisticaloddsandends.wordpress.com/2019/12/09/the-minimax-concave-penalty-mcp/
    abs_x = abs(x)
    if abs_x <= a * pen_val:
        return pen_val * abs_x - x ** 2 / (2 * a)

    else:
        return 0.5 * a * pen_val ** 2