Author: bugman Date: Fri Aug 29 18:24:14 2014 New Revision: 25450 URL: http://svn.gna.org/viewcvs/relax?rev=25450&view=rev Log: Added a script and log for calculating the numerical chi-squared Jacobian for an exponential curve. This uses the data at http://thread.gmane.org/gmane.science.nmr.relax.devel/6807/focus=6840 and calculates the chi-squared Jacobian using the numdifftools.Jacobian object construct and obtain the matrix, both at the minimum and at a point away from the minimum. The values will be used to construct a unit test to check the C module implementation. Added: trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.log trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.py - copied, changed from r25449, trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian.py Added: trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.log URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.log?rev=25450&view=auto ============================================================================== --- trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.log (added) +++ trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.log Fri Aug 29 18:24:14 2014 @@ -0,0 +1,12 @@ + + +On-minimum: + +The Chi2 Jacobian at [1.0, 1000.0] is: +[[ -1.10023306e-09 2.18294730e-12]] + + +Off-minimum: + +The Chi2 Jacobian at [2.0, 500.0] is: +[[ 456.36655522 -10.86133391]] Copied: trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.py (from r25449, trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian.py) URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.py?p2=trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.py&p1=trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian.py&r1=25449&r2=25450&rev=25450&view=diff ============================================================================== --- trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian.py (original) +++ trunk/test_suite/shared_data/curve_fitting/numeric_topology/jacobian_chi2.py Fri Aug 29 18:24:14 2014 @@ -7,7 +7,7 @@ def func(params): - """Back-calculate the intensities.""" + """Calculate the chi-squared value.""" global times, I, errors @@ -19,8 +19,13 @@ for i in range(len(times)): back_calc.append(I0 * exp(-R*times[i])) - # Return the back-calculated intensities. - return array(back_calc) + # The chi2. + chi2 = 0.0 + for i in range(len(times)): + chi2 += (I[i] - back_calc[i])**2 / errors[i]**2 + + # Return the value. + return chi2 # The real parameters. @@ -42,11 +47,11 @@ # The numeric Jacobian at the minimum. print("\n\nOn-minimum:\n") matrix = jacobian([R, I0]) -print("The Jacobian at %s is:\n%s" % ([R, I0], matrix)) +print("The Chi2 Jacobian at %s is:\n%s" % ([R, I0], matrix)) # The numeric Jacobian off the minimum. print("\n\nOff-minimum:\n") R = 2.0 I0 = 500.0 matrix = jacobian([R, I0]) -print("The Jacobian at %s is:\n%s" % ([R, I0], matrix)) +print("The Chi2 Jacobian at %s is:\n%s" % ([R, I0], matrix))