Пример #1
0
def test_yj_transform_2lam():
    lam = 2

    # test for lambda == 2
    res = _yj_transform_y(np.array(y), lam=lam)  # test a copy...
    assert res is not y

    c1 = (lambda x: (np.power(x + 1, lam) - 1.0) / lam)
    c4 = (lambda x: -np.log(-x + 1))
    expected = np.array([
        # case 4
        c4(-2.), c4(-1.),

        # case 1
        c1(0), c1(1), c1(2)
    ])

    assert_array_almost_equal(expected, res)
Пример #2
0
def test_yj_transform_0lam():
    lam = 0

    # test for lambda == 0
    res = _yj_transform_y(np.array(y), lam=lam)  # test a copy...
    assert res is not y

    # denom = 2.0 - lam
    # numer = np.power((-x + 1), (2.0 - lam)) - 1.0
    # return -numer / denom
    c3 = (lambda x: -(np.power((-x + 1), (2.0 - lam)) - 1.0) / (2. - lam))
    expected = np.array([
        # case 3
        c3(-2.), c3(-1.),

        # case 2
        np.log(0 + 1.), np.log(1 + 1.), np.log(2 + 1.)
    ])

    assert_array_almost_equal(expected, res)