Usage:
Description:
Fits the data found in %data to the "FORTRAN-type" equation
supplied as $eq beginning with the estimates found in the list @estimates.
The equation must be passed as a scaler, enclosed in
single quotes, using the following form:
A directory called $dir_name is created, and contains subdirectories
named after all the atoms
found in %data hash. Each of
these subdirectories contains XMGR files
(use: xmgr -batch odrfit.xmgr.batch)
of the fit for that nucleus and
the actual input and output file from the odrpack fit.
In the directory "test" will be a fit_summary.txt file which
summaries the results of the fit.
See the Netlib software repository
http://www.netlib.org/
for more details, especially the section on ODRPACK:
http://www.netlib.org/odrpack/
ODRPACK was created by
Example:
Of course, the data can be read in from a file using the
&readData subroutine.
&fitFunction
Summary:
Fits the free parameters in an arbitrary function to experimental data using
nonlinear least squares.
&fitFunction( $dir_name, \%data, $eq, @estimates );
This subroutine uses the Levenburg-Marquardt algorithm to perform least
squares minimization on a supplied function.
Adapted from Joel Tolmans "lmfit" perl scripts, and his odrfit
driver to the ODRPACK libraries.
$eq = 'f(1,I) = b(1)*exp(-b(2)*x(I))';
which would fit a 2 parameter single exponential fit.
Paul T. Boggs, Richard H. Byrd,
Janet E. Rogers and Robert B. Schnabel
Center for Computing and Applied Mathematics
National Institute of Standards and Technology (NIST)
Gaithersburg, MD 20899
Fitting some experimentally measured R1 relaxation data to
2 parameter single exponential fit, the data is a list of
3 values per data point, X1, Y1, dY1, X2, Y2, dY2, etc...
$atom = "A 1 ARG N";
$data{$atom} = [
0.00, -68.01300, 2.0,
0.25, -52.13200, 2.0,
0.50, -39.70800, 2.0,
0.75, -29.16000, 2.0,
1.00, -22.54300, 2.0,
1.25, -16.90200, 2.0,
1.50, -12.70400, 2.0,
1.75, -9.60580, 2.0,
2.00, -7.24160, 2.0,
2.25, -5.47010, 2.0,
];
$debug=0;
$eq = 'f(1,I) = b(1)*exp(-b(2)*x(I))';
@est = ( 1, 1 );
%fit_data = &fitFunction( \%data, "test", $eq, @est );
($b1, $b1err, $b2, $b2err) = @{ $fit_data{$atom} };
print "b1=$b1($b1err) b2=$b2($b2err)\n";
Which gives as a result:
b1=-6.83877238E+01(2.7622E-01) b2=1.11536372E+00(7.6625E-03)
Additionally, the directory yarm_work/fits/A_1_ARG_N/ contains files
with the the full statistical analysis of the fit (odrfit.out), the
original input file (odrfit.in), the original input data and the fitted
curve (odrfit.xmgr) and an XMGR batch file to fascilitate
visualizing the results by typing "xmgr -batch odrfit.xmgr.batch".