import math


def error_to_alpha(error_rate):
    """
    Given an error rate, convert it to an alpha value -- that is, a weight to
    assign to a base classifier. Low error rates get high alpha values.
    """
    doubt = 1e-4
    error_rate = min(max(error_rate, doubt), 1-doubt)
    return (math.log(1-error_rate) - math.log(error_rate)) * 0.5