sherpa.astro.ui.calc_stat(id=None, *otherids)

Calculate the fit statistic for a data set.

Evaluate the model for one or more data sets, compare it to the data using the current statistic, and return the value. No fitting is done, as the current model parameter, and any filters, are used.

  • id (int or str, optional) – The data set that provides the data. If not given then all data sets with an associated model are used simultaneously.

  • *otherids (int or str, optional) – Other data sets to use in the calculation.


stat – The current statistic value.

Return type


See also


Calculate the per-bin chi-squared statistic.


Display the statistic values for the current models.


Set the statistical method.


Calculate the statistic for the model and data in the default data set:

>>> stat = calc_stat()

Find the statistic for data set 3:

>>> stat = calc_stat(3)

When fitting to multiple data sets, you can get the contribution to the total fit statistic from only one data set, or from several by listing the datasets explicitly. The following finds the contribution from the data sets labelled “core” and “jet”:

>>> stat = calc_stat("core", "jet")

Calculate the statistic value using two different statistics:

>>> set_stat('cash')
>>> s1 = calc_stat()
>>> set_stat('cstat')
>>> s2 = calc_stat()