FitResults

class sherpa.fit.FitResults(fit: Fit, results: tuple[bool, ndarray, float, str, dict[str, Any]], init_stat: float, param_warnings: str)[source] [edit on github]

Bases: NoNewAttributesAfterInit

The results of a fit.

This object contains the parameter values, information on the statistic and optimisation-method used, and other relevant information.

Changed in version 4.10.1: The covarerr attribute has been renamed to covar and now contains the covariance matrix estimated at the best-fit location, if provided by the optimiser.

Changed in version 4.17.1: The record_steps attribute has been added to the class. If the fit recorded the parameter values of each step in the optimization, this attribute will contain an array with the data.

Attributes Summary

succeeded

Was the fit successful (did it converge)?

parnames

The parameter names that were varied in the fit,

parvals

The parameter values, in the same order as parnames.

istatval

The statistic value at the start of the fit.

statval

The statistic value after 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.

rstat

The reduced statistic value (the statval field divided by dof).

message

A message about the results of the fit (e.g. if the fit was unable to converge).

covar

The covariance matrix from the best-fit location, if provided by the optimiser.

nfev

The number of model evaluations made during the fit.

extra_output

The extra_output field from the fit.

record_steps

A record of all steps taken during the fit, if requested with record_steps=True.

modelvals

The values of the best-fit model evaluated for the data.

methodname

The name of the optimisation method used (in lower case).

itermethodname

What iterated-fit scheme was used, if any.

statname

The name of the statistic function.

datasets

A sequence of the data set ids included in the results.

Methods Summary

format()

Return a string representation of the fit results.

Attributes Documentation

succeeded: bool

Was the fit successful (did it converge)?

parnames: tuple[str, ...]

The parameter names that were varied in the fit,

This is the thawed parameters in the model expression.

parvals: tuple[float, ...]

The parameter values, in the same order as parnames.

istatval: float

The statistic value at the start of the fit.

statval: float

The statistic value after the fit.

dstatval: float

The change in the statistic value (istatval - statval).

numpoints: int

The number of bins used in the fits.

dof: int

The number of degrees of freedom in the fit (the number of bins minus the number of free parameters).

qval: float | None

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: float | None

The reduced statistic value (the statval field divided by dof).

This is not calculated for all statistics.

message: str

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.

covar

The covariance matrix from the best-fit location, if provided by the optimiser.

nfev: int

The number of model evaluations made during the fit.

extra_output

The extra_output field from the fit.

record_steps: None | dict

A record of all steps taken during the fit, if requested with record_steps=True.

modelvals: ndarray

The values of the best-fit model evaluated for the data.

methodname: str

The name of the optimisation method used (in lower case).

itermethodname: str | None

What iterated-fit scheme was used, if any.

statname: str

The name of the statistic function.

datasets: list[int | str] | None

A sequence of the data set ids included in the results.

Methods Documentation

format() str[source] [edit on github]

Return a string representation of the fit results.

Returns:

txt – A multi-line representation of the fit results.

Return type:

str