Chi2ConstVar

class sherpa.stats.Chi2ConstVar(name='chi2constvar')[source] [edit on github]

Bases: Chi2

Chi Squared with constant variance.

The variance is the same in each bin, and set to be the mean number of counts in the data:

sigma(i)^2 = (1/K) * (sum)_(j=1)^K N(j,S) + [A(S)/A(B)]^2 N(j,B)

where K is the number of on-source (and off-source) bins included in the fit. The background term appears only if an estimate of the background has been subtracted from the data.

Methods Summary

calc_chisqr(data, model)

Return the chi-square value for each bin.

calc_stat(data, model)

Return the statistic value for the data and model.

calc_staterror(data)

Return the statistic error values for the data.

goodness_of_fit(statval, dof)

Return the reduced statistic and q value.

Methods Documentation

calc_chisqr(data, model) [edit on github]

Return the chi-square value for each bin.

Parameters
Returns

chisqr – The per-bin chi-square values.

Return type

array of numbers

calc_stat(data, model) [edit on github]

Return the statistic value for the data and model.

Parameters
Returns

  • statval (number) – The value of the statistic.

  • fvec (array of numbers) – The per-bin “statistic” value.

static calc_staterror(data)[source] [edit on github]

Return the statistic error values for the data.

Parameters

data (scalar or 1D array of numbers) – The data values.

Returns

staterror – The errors for the input data values (matches the data argument).

Return type

scalar or array of numbers

goodness_of_fit(statval, dof) [edit on github]

Return the reduced statistic and q value.

The reduced statisitc is conceptually simple, as it is just statistic / degrees-of-freedom, but it is not meaningful for all statistics, and it is only valid if there are any degrees of freedom.

Parameters
  • statval (float) – The statistic value. It is assumed to be finite.

  • dof (int) – The number of degrees of freedom, which may be 0 or negative.

Returns

  • rstat (float or NaN or None) – The reduced statistic. If the statistic does not support a goodness of fit then the return value is None. If it does then NaN is returned if either the number of degrees of freedom is 0 (or less), or the statistic value is less than 0.

  • qval (float or NaN or None) – The q value. If the statistic does not support a goodness of fit then the return values are None. If it does then NaN is returned if either the number of degrees of freedom is 0 (or less), or the statistic value is less than 0.