Perform a fit using current optimization method and
fit statistic.
fit( [ id, [otherids], outfile="fit.out", clobber=True])
The fit() function fits the defined model(s) to the data set(s)
by data ID. It may be called with no arguments, in which case
a fit is done simultaneously on all data sets for which the
user has defined a model to be fit.
If a background file and background responses are defined for
the dataset which is being fit, the background is
automatically fit as well.
-
id, otherids - the id(s) of the data set(s) to use;
default is to fit all datasets for which a model has been
defined
-
outfile - name of the file in which to store parameter values
and fit statistic after a fit (e.g., "fit.out")
-
clobber - a Boolean switch which indicates whether or not
the 'outfile' should be overwritten, if the file already exists;
default=True
The fit is done with the specified optimization method and
statistic; the default values are levmar and chi2gehrels,
respectively. The fit proceeds until it converges to within
the set tolerance or hits the maximum number of iterations.
The resulting best fit parameters and final statistic value
are displayed to the user. The best-fit parameters are
accessible with get_fit_results().
A single data set can be fit using its data set ID number or string.
The fit() function called with no arguments will
simultaneously fit all data sets to which
models have been assigned.
sherpa> fit(3, outfile="fit_info.out", clobber=True)
In this example, data set 3 will be fit, and the fit
parameter values and statistic will be stored in the file
"fit_info.out" after the fit evaluation. This file will be
overwritten if it already exists.
sherpa> fit("leg_m1","leg_p1")
When multiple data sets are indicated, a simultaneous fit
is performed and the statistics value is
summed over all the data sets. For
example, one may wish to simultaneously fit a source and
background data set, multiple spectral orders of PHA
grating data, etc. In this example, the LEG +1 and -1
spectral orders of an HRC-S/LETG grating data set are fit
simultaneously by data ID:
sherpa> fit("leg_m1","leg_p1")
LevMar:
Initial fit statistic = 21857.8
Final fit statistic = 6662.04 at function evaluation 52
Data points = 3162
Degrees of freedom = 3158
Probability [Q-value] = 9.26899e-252
Reduced statistic = 2.10958
Change in statistic = 15195.8
bpow.phoindx1 1
bpow.breake 0.763347
bpow.phoindx2 1.79799
bpow.norm 0.0294637
sherpa> print get_fit_results()
methodname = LevMar
succeeded = True
parnames = ('bpow.phoindx1', 'bpow.breake', 'bpow.phoindx2', 'bpow.norm')
parvals = (1.00000005713, 0.763346621728, 1.79799457922, 0.0294636807334)
covarerr = None
statval = 6662.04434909
istatval = 21857.8439964
dstatval = 15195.7996473
numpoints = 3162
dof = 3158
qval = 9.26899264507e-252
rstat = 2.10957705798
message = relative error between two consecutive
iterates is at most xtol=1.19209e-07
nfev = 52
|