def ber(tp, tn, fp, fn):
    """Balanced Error Rate [0, 1]
    
    :param int tp: number of true positives
    :param int tn: number of true negatives
    :param int fp: number of false positives
    :param int fn: number of false negatives
    :rtype: float 
    """
    return (fp / float(tn + fp) + fn / float(fn + tp)) / 2