示例#1
0
    def setUpClass(cls):
        # Create Transformation class
        cls.t1 = pints.IdentityTransformation(1)
        cls.t4 = pints.IdentityTransformation(4)

        cls.p = [-177., 0.333, 10., 99.99]
        cls.x = [-177., 0.333, 10., 99.99]
        cls.j = np.eye(4)
        cls.j_s1 = np.zeros((4, 4, 4))
        cls.log_j_det = 0.
        cls.log_j_det_s1 = np.zeros(4)
示例#2
0
    def test_against_elementwise_transformation(self):
        # Test general case gives the same result as the elementwise case
        t1 = pints.IdentityTransformation(1)  # This is element-wise
        t_elem = pints.ComposedTransformation(t1, self.t2, self.t3)
        self.assertTrue(t_elem.elementwise())  # This is element-wise

        # Test log-Jacobian determinant
        self.assertAlmostEqual(self.t.log_jacobian_det(self.x),
                               t_elem.log_jacobian_det(self.x))

        # Test log-Jacobian determinant derivatives
        _, t_deriv = self.t.log_jacobian_det_S1(self.x)
        _, t_elem_deriv = t_elem.log_jacobian_det_S1(self.x)
        self.assertTrue(np.allclose(t_deriv, t_elem_deriv))
示例#3
0
    def setUpClass(cls):
        # Create Transformation class
        t1 = pints.IdentityTransformation(1)
        lower2 = np.array([1, 2])
        upper2 = np.array([10, 20])
        t2 = pints.RectangularBoundariesTransformation(lower2, upper2)
        t3 = pints.LogTransformation(1)

        cls.t = pints.ComposedTransformation(t1, t2, t3)

        cls.p = [0.1, 1.5, 15., 999.]
        cls.x = [0.1, -2.8332133440562162, 0.9555114450274365,
                 6.9067547786485539]
        cls.j = np.diag([1., 0.4722222222222225, 3.6111111111111098, 999.])
        cls.j_s1_diag = [0., 0.4197530864197533, -1.6049382716049378, 999.]
        cls.j_s1 = np.zeros((4, 4, 4))
        for i in range(4):
            cls.j_s1[i, i, i] = cls.j_s1_diag[i]
        cls.log_j_det = 7.4404646962481324
        cls.log_j_det_s1 = [0., 0.8888888888888888, -0.4444444444444445, 1.]
示例#4
0
 def create_pints_transform(self):
     if False:
         return pints.LogTransformation(n_parameters=1)
     else:
         return pints.IdentityTransformation(n_parameters=1)