Ejemplo n.º 1
0
def test_Ikpw_Jkpw_identities():
    """Test the relations given in Wiktorsson2001 equation (2.1)"""
    dW = deltaW(N, m, h).reshape((N, m, 1))
    A, I = Ikpw(dW, h)
    assert (A.shape == (N, m, m) and I.shape == (N, m, m))
    Im = broadcast_to(np.eye(m), (N, m, m))
    assert (np.allclose(I + _t(I), _dot(dW, _t(dW)) - h * Im))
    assert (np.allclose(A, -_t(A)))
    assert (np.allclose(2.0 * (I - A), _dot(dW, _t(dW)) - h * Im))
    # and tests for Stratonovich case
    A, J = Jkpw(dW, h)
    assert (A.shape == (N, m, m) and J.shape == (N, m, m))
    assert (np.allclose(J + _t(J), _dot(dW, _t(dW))))
    assert (np.allclose(2.0 * (J - A), _dot(dW, _t(dW))))
Ejemplo n.º 2
0
def test_Ikpw_Jkpw_identities():
    """Test the relations given in Wiktorsson2001 equation (2.1)"""
    dW = deltaW(N, m, h).reshape((N, m, 1))
    A, I = Ikpw(dW, h)
    assert(A.shape == (N, m, m) and I.shape == (N, m, m))
    Im = broadcast_to(np.eye(m), (N, m, m))
    assert(np.allclose(I + _t(I), _dot(dW, _t(dW)) - h*Im))
    assert(np.allclose(A, -_t(A)))
    assert(np.allclose(2.0*(I - A), _dot(dW, _t(dW)) - h*Im))
    # and tests for Stratonovich case
    A, J = Jkpw(dW, h)
    assert(A.shape == (N, m, m) and J.shape == (N, m, m))
    assert(np.allclose(J + _t(J), _dot(dW, _t(dW))))
    assert(np.allclose(2.0*(J - A), _dot(dW, _t(dW))))
Ejemplo n.º 3
0
def test_Iwik_Jwik_identities():
    dW = deltaW(N, m, h).reshape((N, m, 1))
    Atilde, I = Iwik(dW, h)
    M = m * (m - 1) // 2
    assert (Atilde.shape == (N, M, 1) and I.shape == (N, m, m))
    Im = broadcast_to(np.eye(m), (N, m, m))
    assert (np.allclose(I + _t(I), _dot(dW, _t(dW)) - h * Im))
    # can get A from Atilde: (Wiktorsson2001 equation between (4.3) and (4.4))
    Ims = broadcast_to(np.eye(m * m), (N, m * m, m * m))
    Pm = broadcast_to(_P(m), (N, m * m, m * m))
    Km = broadcast_to(_K(m), (N, M, m * m))
    A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde))
    # now can test this A against the identities of Wiktorsson eqn (2.1)
    assert (np.allclose(A, -_t(A)))
    assert (np.allclose(2.0 * (I - A), _dot(dW, _t(dW)) - h * Im))
    # and tests for Stratonovich case
    Atilde, J = Jwik(dW, h)
    assert (Atilde.shape == (N, M, 1) and J.shape == (N, m, m))
    assert (np.allclose(J + _t(J), _dot(dW, _t(dW))))
    A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde))
    assert (np.allclose(2.0 * (J - A), _dot(dW, _t(dW))))
Ejemplo n.º 4
0
def test_Iwik_Jwik_identities():
    dW = deltaW(N, m, h).reshape((N, m, 1))
    Atilde, I = Iwik(dW, h)
    M = m*(m-1)/2
    assert(Atilde.shape == (N, M, 1) and I.shape == (N, m, m))
    Im = broadcast_to(np.eye(m), (N, m, m))
    assert(np.allclose(I + _t(I), _dot(dW, _t(dW)) - h*Im))
    # can get A from Atilde: (Wiktorsson2001 equation between (4.3) and (4.4))
    Ims = broadcast_to(np.eye(m*m), (N, m*m, m*m))
    Pm = broadcast_to(_P(m), (N, m*m, m*m))
    Km = broadcast_to(_K(m), (N, M, m*m))
    A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde))
    # now can test this A against the identities of Wiktorsson eqn (2.1)
    assert(np.allclose(A, -_t(A)))
    assert(np.allclose(2.0*(I - A), _dot(dW, _t(dW)) - h*Im))
    # and tests for Stratonovich case
    Atilde, J = Jwik(dW, h)
    assert(Atilde.shape == (N, M, 1) and J.shape == (N, m, m))
    assert(np.allclose(J + _t(J), _dot(dW, _t(dW))))
    A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde))
    assert(np.allclose(2.0*(J - A), _dot(dW, _t(dW))))