Chi2ModVar
- class sherpa.stats.Chi2ModVar(name: str = 'chi2modvar')[source] [edit on github]
Bases:
Chi2
Chi Squared with model amplitude variance.
The variance in each bin is estimated from the model value in that bin. This contrasts with other Chi-squared statics - such as
Chi2DataVar
, Chi2XspecVar`, andChi2Gehrels
- which use the data values. The variance issigma(i)^2 = S(i) + [A(S)/A(B)]^2 B(i,off)
where B(i,off) is the background model amplitude in bin i of the off-source region.
A(B) is the off-source “area”, which could be the size of the region from which the background is extracted, or the length of a background time segment, or a product of the two, etc.; and A(S) is the on-source “area”. These terms may be defined for a particular type of data: for example, PHA data sets A(B) to
BACKSCAL * EXPOSURE
from the background data set and A(S) toBACKSCAL * EXPOSURE
from the source data set.See also
Notes
The background should not be subtracted from the data when this statistic is used, as it underestimates the variance when fitting background-subtracted 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: Data | DataSimulFit, model: Model) ndarray [edit on github]
Return the chi-square value for each bin.
- Parameters:
data (
sherpa.data.Data
orsherpa.data.DataSimulFit
) – The data set, or sets, to use.model (
sherpa.models.model.Model
orsherpa.models.model.SimulFitModel
) – The model expression, or expressions. If asherpa.models.model.SimulFitModel
is given then it must match the number of data sets in the data parameter.
- Returns:
chisqr – The per-bin chi-square values.
- Return type:
array of numbers
- calc_stat(data: Data | DataSimulFit, model: Model) tuple[float, ndarray] [edit on github]
Return the statistic value for the data and model.
- Parameters:
data (
sherpa.data.Data
orsherpa.data.DataSimulFit
) – The data set, or sets, to use.model (
sherpa.models.model.Model
orsherpa.models.model.SimulFitModel
) – The model expression, or expressions. If asherpa.models.model.SimulFitModel
is given then it must match the number of data sets in the data parameter.
- Returns:
statval (number) – The value of the statistic.
fvec (array of numbers) – The per-bin “statistic” value.
- static calc_staterror(data: ndarray) ndarray [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: float, dof: int) tuple[Literal[None], Literal[None]] | tuple[float, float] [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:
- 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.