def test_jacobian_chi2_exp_off_minimum(self): """Unit test for the Jacobian returned by the jacobian_chi2_exp() function at a position away from the minimum. This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/jacobian_chi2.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_chi2_exp(params) # The real Jacobian. real = [[ 0.00000000e+00, -1.00000000e+01], [ 4.06292489e+02, -8.12584978e-01], [ 4.62204173e+01, -4.62204173e-02], [ 3.61013094e+00, -2.40675396e-03], [ 2.43517791e-01, -1.21758895e-04]] # Numpy conversion. matrix = array(matrix) real = transpose(array(real)) # Printout. print("The chi-squared Jacobian at %s is:\n%s" % (params, matrix)) print("The real chi-squared 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)
def test_jacobian_chi2_exp_off_minimum(self): """Unit test for the Jacobian returned by the jacobian_chi2_exp() function at a position away from the minimum. This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/jacobian_chi2.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_chi2_exp(params) # The real Jacobian. real = [[0.00000000e+00, -1.00000000e+01], [4.06292489e+02, -8.12584978e-01], [4.62204173e+01, -4.62204173e-02], [3.61013094e+00, -2.40675396e-03], [2.43517791e-01, -1.21758895e-04]] # Numpy conversion. matrix = array(matrix) real = transpose(array(real)) # Printout. print("The chi-squared Jacobian at %s is:\n%s" % (params, matrix)) print("The real chi-squared 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)
def test_jacobian_chi2_exp(self): """Unit test for the Jacobian returned by the jacobian_chi2_exp() function at the minimum. This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/jacobian_chi2.log. """ # Get the exponential curve Jacobian. matrix = jacobian_chi2_exp(self.params) # The real Jacobian. real = [[ 0.00000000e+00, 0.00000000e+00], [ -3.25440806e-09, 3.25446070e-12], [ 2.09660266e-09, -1.04831421e-12], [ 1.07707223e-10, -3.58994022e-14], [ -5.00778448e-11, 1.25201612e-14]] # Numpy conversion. matrix = array(matrix) real = transpose(array(real)) # Printouts. print("The chi-squared Jacobian at the minimum is:\n%s" % matrix) print("The real chi-squared 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)
def test_jacobian_chi2_exp(self): """Unit test for the Jacobian returned by the jacobian_chi2_exp() function at the minimum. This uses the data from test_suite/shared_data/curve_fitting/numeric_gradient/jacobian_chi2.log. """ # Get the exponential curve Jacobian. matrix = jacobian_chi2_exp(self.params) # The real Jacobian. real = [[0.00000000e+00, 0.00000000e+00], [-3.25440806e-09, 3.25446070e-12], [2.09660266e-09, -1.04831421e-12], [1.07707223e-10, -3.58994022e-14], [-5.00778448e-11, 1.25201612e-14]] # Numpy conversion. matrix = array(matrix) real = transpose(array(real)) # Printouts. print("The chi-squared Jacobian at the minimum is:\n%s" % matrix) print("The real chi-squared 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)