Ejemplo n.º 1
0
 def test_multivariate_normal_size_types(self):
     # Test for multivariate_normal issue with 'size' argument.
     # Check that the multivariate_normal size argument can be a
     # numpy integer.
     rnd.multivariate_normal([0], [[0]], size=1)
     rnd.multivariate_normal([0], [[0]], size=np.int_(1))
     rnd.multivariate_normal([0], [[0]], size=np.int64(1))
Ejemplo n.º 2
0
    def test_multivariate_normal(self):
        rnd.seed(self.seed, self.brng)
        mean = (.123456789, 10)
        # Hmm... not even symmetric.
        cov = [[1, 0], [1, 0]]
        size = (3, 2)
        actual = rnd.multivariate_normal(mean, cov, size)
        desired = np.array([[[-2.42282709811266, 10.0],
                             [1.2267795840027274, 10.0]],
                            [[0.06813924868067336, 10.0],
                             [1.001190462507746, 10.0]],
                            [[-1.74157261455869, 10.0],
                             [1.0400952859037553, 10.0]]])
        np.testing.assert_array_almost_equal(actual, desired, decimal=10)

        # Check for default size, was raising deprecation warning
        actual = rnd.multivariate_normal(mean, cov)
        desired = np.array([1.0579899448949994, 10.0])
        np.testing.assert_array_almost_equal(actual, desired, decimal=10)

        # Check that non positive-semidefinite covariance raises warning
        mean = [0, 0]
        cov = [[1, 1 + 1e-10], [1 + 1e-10, 1]]
        assert_warns(RuntimeWarning, rnd.multivariate_normal, mean, cov)