# curvefit

Perform non-linear curve fitting on given data set.

curvefit <dset> { <equation> | name <dsname> { gauss | nexp <m> [form {mexp|mexpk|mexpk_penalty} } } [AX=<value> ...] [out <outfile>] [resultsout <results>] [maxit <max iterations>] [tol <tolerance>] [outxbins <NX> outxmin <xmin> outxmax <xmax>]

`<dset>`

Data set to fit.

<equation> Equation to fit of form <Variable> = <Equation>. See more details on equations CPPTRAJ understands.

`name <dsname>`

Final data set name (required if using nexp or gauss).

`gauss`

Fit to Gaussian of form A0 * exp( -((X – A1)^2) / (2 * A2^2) )

`nexp <m>`

Fit to specified number of exponentials.

`form <type>`

Fit to specified exponential form:

`mexp`

Multi-exponential, SUM(m)[ An * exp(An+1 * X)]

`mexpk`

Multi-exponential plus constant, A0 + SUM(m)[An * exp(An+1 * X)]

`mexpk_penalty`

Same as mexpk except sum of prefactors constrained to 1.0 and exponential constants constrained to < 0.0.

`AX=<value>`

Value of any constants in specified equation with X starting from 0 (can specify more than one).

`out <outfile>`

Write resulting fit curve to <outfile>.

`resultsout <results>`

Write details of the fit to <results> (default STDOUT).

`maxit <max iterations>`

Number of iterations to run curve fitting algotrithm (default 50).

`tol <tolerance>`

Curve-fitting tolerance (default 1E-4).

`outxbins <NX>`

Number of points to use when generating final curve (default same number of points as input data set).

`outxmin <xmin>`

Minimum X value to use for final curve (default same number of points as input data set).

`outxmax <xmax>`

Maximum X value to use for final curve (default same number of points as input data set).

Perform non-linear curve fitting for the specified data set using the Levenberg-Marquardt algorithm. Any equation form that CPPTRAJ understands can be used, or several preset forms can be used. Similar to Grace, an equation can contain constants for curve fitting termed AX (with X being a numerical digit, one for each constant), and is assigned to a variable which then

becomes a data set.

For example, to fit a curve to data from a file named Data.dat to a data set named ’FitY’:

readdata Data.dat runanalysis curvefit Data.dat \ "FitY = (A0 * exp(X * A1)) + (A2 * exp(X * A3))" \ A0=1 A1=-1 A2=1 A3=-1 \ out curve.dat tol 0.0001 maxit 50

To perform the same fit but to a multi-exponential curve with two exponentials:

readdata Data.dat runanalysis curvefit Data.dat nexp 2 name FitY \ A0=1 A1=-1 A2=1 A3=-1 \ out curve1.dat tol 0.0001 maxit 50