19 lines
407 B
Python
19 lines
407 B
Python
import numpy as np
|
|
|
|
|
|
def aic_statistic(dist, data, axis):
|
|
"""
|
|
AIC-based goodness-of-fit statistic.
|
|
|
|
AIC = 2k - 2ln(L)
|
|
|
|
Lower AIC indicates better fit, but since goodness_of_fit()
|
|
treats larger statistic values as worse fit, AIC works directly.
|
|
"""
|
|
|
|
k = len(dist.args)
|
|
log_likelihood = np.sum(dist.logpdf(data), axis=axis)
|
|
aic = 2 * k - 2 * log_likelihood
|
|
|
|
return aic
|