diffpy.srmise.modelevaluators package
Submodules
diffpy.srmise.modelevaluators.aic module
- class diffpy.srmise.modelevaluators.aic.AIC[source]
Bases:
ModelEvaluator
Evaluate and compare models with the AIC statistic.
Akaike’s Information Criterion (AIC) is a method for comparing statistical models which balances raw goodness-of-fit with model parsimony. Assuming the uncertainties are independent normal random variables the AIC has the special form implemented by this class: AIC = chi^2 + 2*k where chi^2 is the chi-squared statistic, and k is the number of free parameters in the model. This is an asymptotic result for number of independent samples n -> infinity. This is a good approximation for n/k <~ 40.
Lower values of the AIC imply a better model, but note that the value of the statistic has no absolute interpretation, and only differences between two models with the same observed values (and uncertainties) have meaning.
For further details see: Burnham, K. P. and Anderson, D. R. “Model selection and Multimodel Inference: A Practical Information Theoretic Approach.” Springer-Verlag, 2002.
- static akaikeprobs(aics)[source]
Return sequence of Akaike probabilities for sequence of AICs
- Parameters:
aics (array-like) – The sequence of AIC instance.
- Returns:
The sequence of Akaike probabilities
- Return type:
array-like
- static akaikeweights(aics)[source]
Return sequence of Akaike weights for sequence of AICs
- Parameters:
aics (array-like) – The sequence of AIC instance.
- Returns:
The sequence of Akaike weights
- Return type:
array-like
- evaluate(fit, count_fixed=False, kshift=0)[source]
Return quality of fit for given ModelCluster using AIC (Akaike’s Information Criterion).
- Parameters:
fit (ModelCluster instance) – The ModelCluster instance to evaluate.
count_fixed (bool) – Whether fixed parameters are considered. Default is False.
kshift (int) – Treat the model has having this many additional parameters. Negative values also allowed. Default is 0.
- Returns:
quality – The quality of fit for given ModelCluster.
- Return type:
float
- growth_justified(fit, k_prime)[source]
Returns whether adding k_prime parameters to the given model (ModelCluster) is justified given the current quality of the fit.
The assumption is that adding k_prime parameters will result in “effectively 0” chiSquared cost, and so adding it is justified if the cost of adding these parameters is less than the current chiSquared cost. The validity of this assumption (which depends on an unknown chiSquared value) and the impact of the errors used should be examined more thoroughly in the future.
- Parameters:
fit (ModelCluster instance) – The ModelCluster instance to evaluate.
k_prime (int) – The prime number of added parameters in the model.
- Returns:
Whether adding k_prime parameters to the given model is justified.
- Return type:
bool
diffpy.srmise.modelevaluators.aicc module
- class diffpy.srmise.modelevaluators.aicc.AICc[source]
Bases:
ModelEvaluator
Evaluate and compare models with the AICc statistic.
Akaike’s Information Criterion w/ 2nd order correction for small sample sizes (AICc) is a method for comparing statistical models which balances raw goodness-of-fit with model parsimony. Assuming the uncertainties are independent normal random variables the AICc has the special form implemented by this class: AICc = chi^2 + 2*k + 2*k*(k+1)/(n-k-1) where chi^2 is the chi-squared statistic, k is the number of free parameters in the model, and n is the number of data points.
Lower values of the AICc imply a better model, but note that the value of the statistic has no absolute interpretation, and only differences between two models with the same observed values (and uncertainties) have meaning.
For further details see: Burnham, K. P. and Anderson, D. R. “Model selection and Multimodel Inference: A Practical Information Theoretic Approach.” Springer-Verlag, 2002.
- static akaikeprobs(aics)[source]
Return sequence of Akaike probabilities for sequence of AICs
- Parameters:
aics (array-like) – The squence of AIC instances
- Returns:
The sequence of Akaike probabilities
- Return type:
array-like
- static akaikeweights(aics)[source]
Return sequence of Akaike weights for sequence of AICs
- Parameters:
aics (array-like) – The squence of AIC instances
- Returns:
The sequence of Akaike weights
- Return type:
array-like
- evaluate(fit, count_fixed=False, kshift=0)[source]
Return quality of fit for given ModelCluster using AICc (Akaike’s Information Criterion with 2nd order correction for small sample size).
Parameters fit: A ModelCluster
The ModelCluster to evaluate.
- count_fixedbool
Whether fixed parameters are considered. Default is False.
- kshiftint
Treat the model has having this many additional parameters. Negative values also allowed. Default is 0.
- Returns:
Quality of AICc
- Return type:
float
- growth_justified(fit, k_prime)[source]
Is adding k_prime parameters to ModelCluster justified given the current quality of the fit.
The assumption is that adding k_prime parameters will result in “effectively 0” chiSquared cost, and so adding it is justified if the cost of adding these parameters is less than the current chiSquared cost. The validity of this assumption (which depends on an unknown chiSquared value) and the impact of the errors used should be examined more thoroughly in the future.
- Parameters:
fit (ModelCluster) – The ModelCluster to evaluate.
k_prime (int) – The prime number of parameters to add.
- Returns:
Whether the current model cluster is justified or not.
- Return type:
bool
- minpoints(npars)[source]
Calculates the minimum number of points required to make an estimate of a model’s quality.
- Parameters:
npars (int) – The number of points required to make an estimate of a model’s quality.
- Returns:
The minimum number of points required to make an estimate of a model’s quality.
- Return type:
int