Exemplo n.º 1
0
def test_pull_asym_asym():
    '''
    Test the "pull" function with asymmetric errors in the values and in the
    reference
    '''
    values = np.array([4, 20, 13])
    values_err = np.array([
        np.array([3,  6, 12]),
        np.array([4,  8,  5])
    ])
    ref = np.array([9, 10, 26])
    ref_err = np.array([
        np.array([3,  6, 12]),
        np.array([4,  8,  5])
    ])

    pull, perr = hep_spt.pull(values, values_err, ref, ref_err)

    assert perr.shape == (2, len(values))

    p = values - ref

    assert np.all(pull[p >= 0] >= 0)
    assert np.all(pull[p < 0] < 0)
    assert np.allclose(pull, [-1, +1, -1])
Exemplo n.º 2
0
def test_pull_asym():
    '''
    Test the "pull" function with asymmetric errors.
    '''
    size = 1000
    data = np.random.normal(0, 2, size)

    values, edges, ex, ey = hep_spt.errorbar_hist(data, uncert='freq')

    centers = hep_spt.cfe(edges)

    rv = norm.pdf(centers)
    ref = float(size)*rv/rv.sum()

    pull, perr = hep_spt.pull(values, ey, ref)

    assert perr.shape == (2, len(values))

    p = values - ref

    assert np.all(pull[p >= 0] >= 0)
    assert np.all(pull[p < 0] < 0)