def test_from_product(): d1 = MultiNorm(mean=[0, 0]) d2 = MultiNorm(mean=[2, 4]) mn = MultiNorm.from_product([d1, d2]) assert_allclose(mn.mean, [1, 2]) assert_allclose(mn.cov, [[0.5, 0], [0, 0.5]])
def test_from_product_numerics(mn3): # Check that `from_product` gives good results # even if some parameters are very small and others very large # Product of 10 measurements should reduce variance by factor 10 mn = MultiNorm.from_product([mn3] * 10) assert_allclose(mn.cov, np.diag([1e-21, 0.1, 1e19]))