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

Calculate the per-bin chi-squared statistic.

Evaluate the model for one or more data sets, compare it to the data using the current statistic, and return an array of chi-squared values for each bin. 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.


chisq – The chi-square value for each bin of the data, using the current statistic (as set by set_stat). A value of None is returned if the statistic is not a chi-square distribution.

Return type

array or None

See also


Calculate the fit statistic for a data set.


Display the statistic values for the current models.


Set the statistical method.


The output array length equals the sum of the arrays lengths of the requested data sets.


When called with no arguments, the return value is the chi-squared statistic for each bin in the data sets which have a defined model.

>>> calc_chisqr()

Supplying a specific data set ID to calc_chisqr - such as “1” or “src” - will return the chi-squared statistic array for only that data set.

>>> calc_chisqr(1)
>>> calc_chisqr("src")

Restrict the calculation to just datasets 1 and 3:

>>> calc_chisqr(1, 3)