Пример #1
0
    def test_kalman_pred_ma(self):
        zero_matrix = np.matrix(np.zeros([2, 2]))
        one_matrix = np.matrix([[1]])
        F = np.matrix([[0, 1], [0, 0]])
        G = np.matrix([[0.5, 1]])
        S = np.matrix([[0], [0]])
        R = np.matrix([[0]])
        Q = np.matrix([[0, 0], [0, 1]])
        ma_model = StateSpaceModel(F, G, Q, R, S)

        np.testing.assert_equal(ma_model.get_pred_delta(1), one_matrix)
        np.testing.assert_equal(ma_model.get_pred_theta(1), np.matrix([[1], [0]]))
        np.testing.assert_equal(ma_model.get_pred_psi(1), zero_matrix)
        np.testing.assert_equal(ma_model.get_pred_pi(1), Q)
        np.testing.assert_equal(ma_model.get_error_cov_matrix(1), Q)

        np.testing.assert_equal(ma_model.get_pred_delta(2), one_matrix)
        np.testing.assert_equal(ma_model.get_pred_theta(2), np.matrix([[1], [0]]))
        np.testing.assert_equal(ma_model.get_pred_pi(2), np.matrix([[1, 0], [0, 1]]))
        np.testing.assert_equal(ma_model.get_pred_psi(2), np.matrix([[1, 0], [0, 0]]))
        np.testing.assert_equal(ma_model.get_error_cov_matrix(2), np.matrix([[0, 0], [0, 1]]))
Пример #2
0
    def test_kalman_pred_mini(self):
        zero_matrix = np.matrix([[0]])
        one_matrix = np.matrix([[1]])
        F = np.matrix([[0]])
        G = np.matrix([[0]])
        S = np.matrix([[0]])
        R = np.matrix([[0]])
        Q = np.matrix([[1]])
        noise_model = StateSpaceModel(F, G, Q, R, S)

        np.testing.assert_equal(noise_model.get_pred_delta(10), zero_matrix)
        np.testing.assert_equal(noise_model.get_pred_theta(10), zero_matrix)
        np.testing.assert_equal(noise_model.get_pred_psi(10), zero_matrix)
        np.testing.assert_equal(noise_model.get_pred_pi(10), one_matrix)
        np.testing.assert_equal(noise_model.get_error_cov_matrix(10), one_matrix)