def test_optimized_A_and_?_w_make_eye(cls):
""" I = (V^T)(?_w)(V), where A = inv(V^T)
NOTES:
(1) There are two ways to compute ?_w:
?_w = (A)(A^T)
?_w = n / (n-1) * S_w
(2) *** COMPUTE PHI WITH S_w: ?_w = n/(n-1) * S_w. ***
(3) Do NOT use ?_w = (A)(A^T) because that is trivially true:
(V^T)(?_w)(V), where V = inv(A^T), which gives
(inv(A))(A)(A^T)(inv(A^T)) = (I)(I) = I.
"""
tolerance = 1e-13 # Should be smaller than n / (n - 1).
S_w = cls.model.S_w
n = cls.model.n_avg
V = inv(cls.model.A.T)
cls.assertTrue(tolerance < (n / (n - 1)))
?_w = n / (n - 1) * S_w
result = np.matmul(np.matmul(V.T, ?_w), V)
cls.assert_same(result, np.eye(cls.dims), tolerance=tolerance)
评论列表
文章目录