def threshold(data, delta=1e-07):
    """
    给定一组成双峰分布的数据 data 计算双峰之间的分界值

    Args:
        data : numpy.array
        delta: 精确度，默认 delta = 1e-7
    """
    threshold = m1 = m2 = data.mean()
    while True:
        g1 = data[data < threshold]
        g2 = data[data > threshold]
        m1 = g1.mean()
        m2 = g2.mean()
        t = (m1 + m2) / 2
        if abs(threshold - t) < delta:
            break
        threshold = t
    return threshold
