import math


def logistic(x):
    """
    Returns a value between 0 and 1 for x in the range [0, inf] and -1 to 1
    for x in the range [-inf, inf].
    """
    return 2.0 / (1 + math.exp(-x)) - 1.0