Last modified: December 2023

Jump to: Description · Examples · PARAMETERS · Notes · Bugs · See Also

AHELP for CIAO 4.16 Sherpa


Context: fitting


Return the results of the last fit.




This function returns the results from the most-recent fit. The returned value includes information on the parameter values and fit statistic.


Example 1

Display the fit results:

>>> print(get_fit_results())

Example 2

Inspect the fit results:

>>> res = get_fit_results()
>>> res.statval
>>> res.dof
>>> res.parnames
('pl.gamma', 'pl.ampl', 'gline.fwhm', 'gline.pos', 'gline.ampl')
>>> res.parvals
(-0.20659543380329071, 0.00030398852609788524, 100.0, 4900.0, 0.001)


This function has no parameters

Return value

The return value from this function is:

stats -- The results of the last fit. It does not reflect any changes made to the model parameter, or settings, since the last fit.


The fields of the object include:

Item Definition
datasets A sequence of the data set ids included in the results.
itermethodname What iterated-fit scheme was used, if any (as set by `set_iter_method` ).
statname The name of the statistic function (as used in `set_stat` ).
succeeded Was the fit successful (did it converge)?
parnames A tuple of the parameter names that were varied in the fit (the thawed parameters in the model expression).
parvals A tuple of the parameter values, in the same order as parnames .
statval The statistic value after the fit.
istatval The statistic value at the start of the fit.
dstatval The change in the statistic value ( istatval - statval ).
numpoints The number of bins used in the fits.
dof The number of degrees of freedom in the fit (the number of bins minus the number of free parameters).
qval The Q-value (probability) that one would observe the reduced statistic value, or a larger value, if the assumed model is true and the current model parameters are the true parameter values. This will be none if the value can not be calculated with the current statistic (e.g. the Cash statistic).
rstat The reduced statistic value (the statval field divided by dof ). This is not calculated for all statistics.
message A message about the results of the fit (e.g. if the fit was unable to converge). The format and contents depend on the optimisation method.
nfev The number of model evaluations made during the fit.


See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

fit, get_stat_info