set_stat
- sherpa.astro.ui.set_stat(stat: str | Stat) None
Set the statistical method.
Changes the method used to evaluate the fit statistic, that is the numerical measure that determines how closely the model represents the data.
Changed in version 4.18.0: The cstatnegativepenalty statistic has been added.
- Parameters:
stat (str or sherpa.stats.Stat instance) – When a string, the name of the statistic (case is not important): see
list_stats()for supported values. Otherwise an instance of the statistic to use.- Raises:
sherpa.utils.err.ArgumentErr – If the
statargument is not recognized.
See also
calc_statCalculate the statistic value for a dataset.
get_stat_nameReturn the current statistic method.
list_statsList the supported fit statistics.
load_user_statCreate a user-defined statistic.
Notes
The available statistics include:
- cash
A maximum likelihood function [1].
- chi2
Chi-squared statistic using the supplied error values.
- chi2constvar
Chi-squared with constant variance computed from the counts data.
- chi2datavar
Chi-squared with data variance. If the data has 0 counts then the error for that bin is 0.
- chi2gehrels
Chi-squared with gehrels method [2]. This is the default method.
- chi2modvar
Chi-squared with model amplitude variance.
- chi2xspecvar
Chi-squared with data variance to match XSPEC. Errors from zero-count channels (source or background) are ignored if the other channel (background or source) contains counts, or replaced by a minimum value (when both source or background are empty). It should not be used when a model is fit to the background rather than the background is subtracted from the data.
- cstat
A maximum likelihood function (the XSPEC implementation of the Cash function) [3]. This does not include support for including the background.
- cstatnegativepenalty
The cstat statistic penalizes models that predict negative values with a constant term. This can cause the optimiser problems, potentially leading to the fit getting stuck. This statistic applies a variable penalty, which may allow the optimiser to move the search back into a valid space.
- wstat
A maximum likelihood function which includes the background data as part of the fit (i.e. for when it is not being explicitly modelled) (the XSPEC implementation of the Cash function) [3].
- leastsq
The least-squares statisic (the error is not used in this statistic).
References
Examples
>>> set_stat('cash')