ruff for code formatting

BIC statistic AND BIC test implemented

test_distributions.py for test new created dists with pytest

REFACTOR:
k_gen pdf changed from 2 params to generalized
This commit is contained in:
2026-04-16 11:52:44 -03:00
parent 9aa97fc3d4
commit d07590e73d
6 changed files with 338 additions and 22 deletions

View File

@@ -16,3 +16,20 @@ def aic_statistic(dist, data, axis):
aic = 2 * k - 2 * log_likelihood
return aic
def bic_statistic(dist, data, axis):
"""
BIC-based goodness-of-fit statistic.
BIC = ln(n)k - 2ln(L)s
Lower BIC indicates better fit, but since goodness_of_fit()
treats larger statistic values as worse fit, BIC works directly.
"""
n = data.size if axis is None else data.shape[axis]
k = len(dist.args)
log_likelihood = np.sum(dist.logpdf(data), axis=axis)
bic = np.log(n) * k - 2 * log_likelihood
return bic