コード例 #1
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_compute_K(self):
        """Tests if K is correctly computed.
        """
        S = self.S_2x3

        expected_K = np.zeros((S.shape[0], S.shape[0]))
        for i in range(0, S.shape[0]):
            for j in range(0, S.shape[0]):
                s1 = np.array([S[i, :]])
                s2 = np.array([S[j, :]])
                exponent = (-self.a_1 * np.power(npla.norm(s1 - s2), 2) / 
                            (2 * (self.sigma_05 ** 2)))
                expected_K[i, j] = np.exp(exponent)

        crkr = CrKr(S, self.C_2x2, self.D_2x3, 
                    self.ridge_factor_05, self.sigma_05, self.a_1)

        assert_true(np.allclose(expected_K, crkr._compute_K()))
コード例 #2
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_compute_K(self):
        """Tests if K is correctly computed.
        """
        S = self.S_2x3

        expected_K = np.zeros((S.shape[0], S.shape[0]))
        for i in range(0, S.shape[0]):
            for j in range(0, S.shape[0]):
                s1 = np.array([S[i, :]])
                s2 = np.array([S[j, :]])
                exponent = (-self.a_1 * np.power(npla.norm(s1 - s2), 2) /
                            (2 * (self.sigma_05**2)))
                expected_K[i, j] = np.exp(exponent)

        crkr = CrKr(S, self.C_2x2, self.D_2x3, self.ridge_factor_05,
                    self.sigma_05, self.a_1)

        assert_true(np.allclose(expected_K, crkr._compute_K()))
コード例 #3
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_delta_mean(self):
        """Tests if delta mean is correctly computed.
        """
        S = self.S_2x3
        C = self.C_2x2
        D = self.D_2x3
        ridge_factor = self.ridge_factor_05
        sigma = self.sigma_05
        a = self.a_1

        crkr = CrKr(S, C, D, ridge_factor, sigma, a)
        
        new_s = np.array([[0, 0, 0]])
        k = crkr._compute_k(new_s)
        K = crkr._compute_K()
        expected_dm = np.dot(k.T, 
                             np.dot(np.linalg.inv(K + ridge_factor * C), D))
        
        assert_true(np.allclose(expected_dm, crkr._delta_mean(k, K)))
コード例 #4
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_delta_mean(self):
        """Tests if delta mean is correctly computed.
        """
        S = self.S_2x3
        C = self.C_2x2
        D = self.D_2x3
        ridge_factor = self.ridge_factor_05
        sigma = self.sigma_05
        a = self.a_1

        crkr = CrKr(S, C, D, ridge_factor, sigma, a)

        new_s = np.array([[0, 0, 0]])
        k = crkr._compute_k(new_s)
        K = crkr._compute_K()
        expected_dm = np.dot(k.T, np.dot(np.linalg.inv(K + ridge_factor * C),
                                         D))

        assert_true(np.allclose(expected_dm, crkr._delta_mean(k, K)))
コード例 #5
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_delta_variance(self):
        """Tests if delta variance is correctly computed.
        """
        S = self.S_2x3
        C = self.C_2x2
        D = self.D_2x3
        ridge_factor = self.ridge_factor_05
        sigma = self.sigma_05
        a = self.a_1

        crkr = CrKr(S, C, D, ridge_factor, sigma, a)

        new_s = np.array([[1, 1, 1]])
        k = crkr._compute_k(new_s)
        K = crkr._compute_K()

        expected_dv = (a + ridge_factor -
                       np.dot(k.T, np.dot(npla.inv(K + ridge_factor * C), k)))

        assert_true(np.allclose(expected_dv, crkr._delta_variance(k, K)))
コード例 #6
0
ファイル: test_crkr.py プロジェクト: rui-silva/CrKr
    def test_delta_variance(self):
        """Tests if delta variance is correctly computed.
        """
        S = self.S_2x3
        C = self.C_2x2
        D = self.D_2x3
        ridge_factor = self.ridge_factor_05
        sigma = self.sigma_05
        a = self.a_1

        crkr = CrKr(S, C, D, ridge_factor, sigma, a)

        new_s = np.array([[1, 1, 1]])
        k = crkr._compute_k(new_s)
        K = crkr._compute_K()

        expected_dv = (a + 
                       ridge_factor - 
                       np.dot(k.T, np.dot(npla.inv(K + ridge_factor * C), k)))

        assert_true(np.allclose(expected_dv, crkr._delta_variance(k, K)))