Exemple #1
0
    def test_cases(self):
        # Test against known results
        for unconstrained, error_variance, constrained in self.cases:
            result = tools.constrain_stationary_multivariate(
                unconstrained, error_variance)
            assert_allclose(result[0], constrained)

        # Test that the constrained results correspond to companion matrices
        # with eigenvalues less than 1 in modulus
        for unconstrained in self.eigval_cases:
            if type(unconstrained) == list:
                cov = np.eye(unconstrained[0].shape[0])
            else:
                cov = np.eye(unconstrained.shape[0])
            constrained, _ = tools.constrain_stationary_multivariate(unconstrained, cov)
            companion = tools.companion_matrix(
                [1] + [-constrained[i] for i in range(len(constrained))]
            ).T
            assert_equal(np.max(np.abs(np.linalg.eigvals(companion))) < 1, True)
Exemple #2
0
    def test_cases(self):
        # Test against known results
        for unconstrained, error_variance, constrained in self.cases:
            result = tools.constrain_stationary_multivariate(
                unconstrained, error_variance)
            assert_allclose(result[0], constrained)

        # Test that the constrained results correspond to companion matrices
        # with eigenvalues less than 1 in modulus
        for unconstrained in self.eigval_cases:
            if type(unconstrained) == list:
                cov = np.eye(unconstrained[0].shape[0])
            else:
                cov = np.eye(unconstrained.shape[0])
            constrained, _ = tools.constrain_stationary_multivariate(
                unconstrained, cov)
            companion = tools.companion_matrix(
                [1] + [-constrained[i] for i in range(len(constrained))]).T
            assert_equal(
                np.max(np.abs(np.linalg.eigvals(companion))) < 1, True)
Exemple #3
0
 def test_cases(self):
     for polynomial, result in self.cases:
         assert_equal(tools.companion_matrix(polynomial), result)
Exemple #4
0
 def test_cases(self):
     for polynomial, result in self.cases:
         assert_equal(tools.companion_matrix(polynomial), result)