(self)
| 772 | assert_array_equal(actual, desired) |
| 773 | |
| 774 | def test_multivariate_normal(self): |
| 775 | rng = random.RandomState(self.seed) |
| 776 | mean = (.123456789, 10) |
| 777 | cov = [[1, 0], [0, 1]] |
| 778 | size = (3, 2) |
| 779 | actual = rng.multivariate_normal(mean, cov, size) |
| 780 | desired = np.array([[[1.463620246718631, 11.73759122771936], |
| 781 | [1.622445133300628, 9.771356667546383]], |
| 782 | [[2.154490787682787, 12.170324946056553], |
| 783 | [1.719909438201865, 9.230548443648306]], |
| 784 | [[0.689515026297799, 9.880729819607714], |
| 785 | [-0.023054015651998, 9.201096623542879]]]) |
| 786 | |
| 787 | assert_array_almost_equal(actual, desired, decimal=15) |
| 788 | |
| 789 | # Check for default size, was raising deprecation warning |
| 790 | actual = rng.multivariate_normal(mean, cov) |
| 791 | desired = np.array([0.895289569463708, 9.17180864067987]) |
| 792 | assert_array_almost_equal(actual, desired, decimal=15) |
| 793 | |
| 794 | # Check that non positive-semidefinite covariance warns with |
| 795 | # RuntimeWarning |
| 796 | mean = [0, 0] |
| 797 | cov = [[1, 2], [2, 1]] |
| 798 | pytest.warns(RuntimeWarning, rng.multivariate_normal, mean, cov) |
| 799 | |
| 800 | # and that it doesn't warn with RuntimeWarning check_valid='ignore' |
| 801 | assert_no_warnings(rng.multivariate_normal, mean, cov, |
| 802 | check_valid='ignore') |
| 803 | |
| 804 | # and that it raises with RuntimeWarning check_valid='raises' |
| 805 | assert_raises(ValueError, rng.multivariate_normal, mean, cov, |
| 806 | check_valid='raise') |
| 807 | |
| 808 | cov = np.array([[1, 0.1], [0.1, 1]], dtype=np.float32) |
| 809 | with warnings.catch_warnings(): |
| 810 | warnings.simplefilter('error') |
| 811 | rng.multivariate_normal(mean, cov) |
| 812 | |
| 813 | def test_negative_binomial(self): |
| 814 | rng = random.RandomState(self.seed) |
nothing calls this directly
no test coverage detected