Example #1
0
    def test_jacobian_exp_off_minimum(self):
        """Unit test for the Jacobian returned by the jacobian_exp() function at a position away from the minimum.

        This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/Hessian.log.
        """

        # The off-minimum parameter values.
        I0 = 500.0
        R = 2.0
        params = [R/self.scaling_list[0], I0/self.scaling_list[1]]

        # Get the exponential curve Jacobian.
        matrix = jacobian_exp(params)

        # The real Jacobian.
        real = [[  0.00000000e+00,   1.00000000e+00],
                [ -6.76676416e+01,   1.35335283e-01],
                [ -1.83156389e+01,   1.83156389e-02],
                [ -3.71812826e+00,   2.47875218e-03],
                [ -6.70925256e-01,   3.35462628e-04]]

        # Numpy conversion.
        matrix = array(matrix)
        real = transpose(array(real))

        # Printout.
        print("The Jacobian at %s is:\n%s" % (params, matrix))
        print("The real Jacobian at the minimum is:\n%s" % real)

        # Check that the Jacobian matches the numerically derived values.
        for i in range(len(matrix)):
            for j in range(len(matrix[i])):
                self.assertAlmostEqual(matrix[i, j], real[i, j], 3)
Example #2
0
    def test_jacobian_exp_off_minimum(self):
        """Unit test for the Jacobian returned by the jacobian_exp() function at a position away from the minimum.

        This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/Hessian.log.
        """

        # The off-minimum parameter values.
        I0 = 500.0
        R = 2.0
        params = [R / self.scaling_list[0], I0 / self.scaling_list[1]]

        # Get the exponential curve Jacobian.
        matrix = jacobian_exp(params)

        # The real Jacobian.
        real = [[0.00000000e+00, 1.00000000e+00],
                [-6.76676416e+01, 1.35335283e-01],
                [-1.83156389e+01, 1.83156389e-02],
                [-3.71812826e+00, 2.47875218e-03],
                [-6.70925256e-01, 3.35462628e-04]]

        # Numpy conversion.
        matrix = array(matrix)
        real = transpose(array(real))

        # Printout.
        print("The Jacobian at %s is:\n%s" % (params, matrix))
        print("The real Jacobian at the minimum is:\n%s" % real)

        # Check that the Jacobian matches the numerically derived values.
        for i in range(len(matrix)):
            for j in range(len(matrix[i])):
                self.assertAlmostEqual(matrix[i, j], real[i, j], 3)
Example #3
0
    def test_jacobian_exp(self):
        """Unit test for the Jacobian returned by the jacobian_exp() function at the minimum.

        This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/Hessian.log.
        """

        # Get the exponential curve Jacobian.
        matrix = jacobian_exp(self.params)

        # The real Jacobian.
        real = [[  0.00000000e+00,   1.00000000e+00],
                [ -3.67879441e+02,   3.67879441e-01],
                [ -2.70670566e+02,   1.35335283e-01],
                [ -1.49361205e+02,   4.97870684e-02],
                [ -7.32625556e+01,   1.83156389e-02]]

        # Numpy conversion.
        matrix = array(matrix)
        real = transpose(array(real))

        # Printouts.
        print("The Jacobian at the minimum is:\n%s" % matrix)
        print("The real Jacobian at the minimum is:\n%s" % real)

        # Check that the Jacobian matches the numerically derived values.
        for i in range(len(matrix)):
            for j in range(len(matrix[i])):
                self.assertAlmostEqual(matrix[i, j], real[i, j], 3)
Example #4
0
    def test_jacobian_exp(self):
        """Unit test for the Jacobian returned by the jacobian_exp() function at the minimum.

        This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/Hessian.log.
        """

        # Get the exponential curve Jacobian.
        matrix = jacobian_exp(self.params)

        # The real Jacobian.
        real = [[0.00000000e+00, 1.00000000e+00],
                [-3.67879441e+02, 3.67879441e-01],
                [-2.70670566e+02, 1.35335283e-01],
                [-1.49361205e+02, 4.97870684e-02],
                [-7.32625556e+01, 1.83156389e-02]]

        # Numpy conversion.
        matrix = array(matrix)
        real = transpose(array(real))

        # Printouts.
        print("The Jacobian at the minimum is:\n%s" % matrix)
        print("The real Jacobian at the minimum is:\n%s" % real)

        # Check that the Jacobian matches the numerically derived values.
        for i in range(len(matrix)):
            for j in range(len(matrix[i])):
                self.assertAlmostEqual(matrix[i, j], real[i, j], 3)