Exemplo n.º 1
0
def test_K():
    """Test matrix _K(m) against relations in Wiktorsson2001 equation (4.3)"""
    for q in range(2, 10):
      P0 = _P(q)
      K0 = _K(q)
      M = q*(q-1)/2
      Iqs = np.eye(q**2)
      IM = np.eye(M)
      assert(np.allclose(np.dot(K0, K0.T), IM))
      d = []
      for k in range(1, q+1):
          d.extend([0]*k + [1]*(q-k))
      assert(np.allclose(np.dot(K0.T, K0), np.diag(d)))
      assert(np.allclose(K0.dot(P0).dot(K0.T), np.zeros((M, M))))
      assert(np.allclose(K0.dot(Iqs).dot(K0.T), IM))
      assert(np.allclose((Iqs - P0).dot(K0.T).dot(K0).dot(Iqs - P0), Iqs - P0))
Exemplo n.º 2
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))))
Exemplo 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))))