def linear(x, root):
    """ Returns a decay factor based on the linear function

        .. math::
            f(x) = \\begin{cases} -x/root + 1  & \\mbox{if} x < root; \\\\
                                  0            & otherwise.
                   \\end{cases}

        :param x: The function argument *x*.
        :param root: The value of *x* after which the decay factor is zero.
    """
    return 1 - min(x, root) / root