Stat

class sherpa.stats.Stat(name)[source] [edit on github]

Bases: sherpa.utils.NoNewAttributesAfterInit

The base class for calculating a statistic given data and model.

Methods Summary

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_stat(data, model)[source] [edit on github]

Return the statistic value for the data and model.

Parameters
  • data (a Data or DataSimulFit instance) – The data set, or sets, to use.

  • model (a Model or SimulFitModel instance) – The model expression, or expressions. If a SimulFitModel is given then it must match the number of data sets in the data parameter.

Returns

statval, fvec – The statistic value and the per-bin “statistic” value.

Return type

number, array of numbers

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)[source] [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, qval – The reduced statistic and 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.

Return type

float or NaN or None, float or NaN or None