예제 #1
0
def test_prbnormndpc():

    rho2 = np.random.rand(2)
    a2 = np.zeros(2)
    b2 = np.repeat(np.inf, 2)
    val2, err2, _ift2 = prbnormndpc(rho2, a2, b2)

    def g2(x):
        return 0.25 + np.arcsin(x[0] * x[1]) / (2 * pi)

    E2 = g2(rho2)  # exact value
    assert (np.abs(E2 - val2) < err2)

    rho3 = np.random.rand(3)
    a3 = np.zeros(3)
    b3 = np.repeat(inf, 3)
    val3, err3, _ift3 = prbnormndpc(rho3, a3, b3)

    def g3(x):
        return 0.5 - sum(
            np.sort(np.arccos([x[0] * x[1], x[0] * x[2], x[1] * x[2]
                               ]))) / (4 * pi)

    E3 = g3(rho3)  # Exact value
    assert (np.abs(E3 - val3) < err3)
예제 #2
0
def test_prbnormndpc():

    rho2 = np.random.rand(2)
    a2 = np.zeros(2)
    b2 = np.repeat(np.inf, 2)
    [val2, err2, ift2] = prbnormndpc(rho2, a2, b2)
    g2 = lambda x: 0.25 + np.arcsin(x[0] * x[1]) / (2 * pi)
    E2 = g2(rho2)  # % exact value
    assert(np.abs(E2 - val2) < err2)

    rho3 = np.random.rand(3)
    a3 = np.zeros(3)
    b3 = np.repeat(inf, 3)
    [val3, err3, ift3] = prbnormndpc(rho3, a3, b3)
    g3 = lambda x: 0.5 - sum(np.sort(np.arccos([x[0] * x[1], x[0] * x[2],
                                                x[1] * x[2]]))) / (4 * pi)
    E3 = g3(rho3)  # Exact value
    assert(np.abs(E3 - val3) < err3)
예제 #3
0
def test_prbnormndpc():

    rho2 = np.random.rand(2)
    a2 = np.zeros(2)
    b2 = np.repeat(np.inf, 2)
    val2, err2, _ift2 = prbnormndpc(rho2, a2, b2)

    def g2(x):
        return 0.25 + np.arcsin(x[0] * x[1]) / (2 * pi)
    E2 = g2(rho2)  # exact value
    assert(np.abs(E2 - val2) < err2)

    rho3 = np.random.rand(3)
    a3 = np.zeros(3)
    b3 = np.repeat(inf, 3)
    val3, err3, _ift3 = prbnormndpc(rho3, a3, b3)

    def g3(x):
        return 0.5 - sum(np.sort(np.arccos([x[0] * x[1], x[0] * x[2],
                                            x[1] * x[2]]))) / (4 * pi)
    E3 = g3(rho3)  # Exact value
    assert(np.abs(E3 - val3) < err3)