def bin_centers(x):
    """
    Given a list of bin edges, return a list of bin centers.
    Useful primarily when plotting histograms.
    """
    return [(a + b) / 2.0 for a, b in zip(x[:-1], x[1:])]