Beispiel #1
0
    def test_set_var(self):
        S = np.array([[0, 0], [0, 2]])

        data = np.array([[1, 3], [1, 6]])
        mixture = PCAMixture(data, 1, 2)
        model = PCAModel(mixture, 2)
        model.S = S
        W_old = np.array([[1, 1], [3, 2]])
        M_inv_old = np.array([[17, -7], [-7, 9]]) / 104
        model.W = np.array([[0, 0], [104 / 87, 208 / 261]])

        model.set_var(W_old, M_inv_old)

        self.assertAlmostEqual(model.var, 52 / 87)
Beispiel #2
0
    def test_set_W(self):
        S = np.array([[0, 0], [0, 2]])
        M_inv = np.array([[17, -7], [-7, 9]]) / 104
        W = np.array([[1, 1], [3, 2]])

        data = np.array([[1, 3], [1, 6]])
        mixture = PCAMixture(data, 1, 2)
        model = PCAModel(mixture, 2)
        model.var = 3
        model.S = S
        model.M_inv = M_inv
        model.W = W

        model.set_W()
        new_W = model.W

        #print(new_W)

        res = np.isclose(new_W, np.array([[0, 0], [104 / 87, 208 / 261]]))
        self.assertTrue(res.all())