def exponential(x, halflife):
    """ Returns a decay factor based on the exponential function

        .. math::
            f(x) = 2^(-x/halflife).

        :param x: The function argument.
        :param halflife: The half-life of the decay process.
    """
    return 2 ** (-x / halflife)