import operator


def get_ecdf(array, reverse=False):
    """
    Generate the empirical distribution function.
    :param array: array_like
    :param reverse: bool
    :return: float -> float
    """
    n = len(array)
    op = operator.ge if reverse else operator.le

    def ecdf(t):
        m = sum(op(x, t) for x in array)  # x <= t or x >= t if reverse
        return float(m) / float(n)

    return ecdf