From 9815c0df400c26f491e720ea2d3b4f7d4800f422 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 17 Dec 2023 16:10:35 +0000 Subject: [PATCH] fit statistics with extra term to avoid division by zero; (#186) closes #181 Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/186 --- src/nmreval/fit/result.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/nmreval/fit/result.py b/src/nmreval/fit/result.py index 27b293b..87fa94f 100644 --- a/src/nmreval/fit/result.py +++ b/src/nmreval/fit/result.py @@ -157,15 +157,12 @@ class FitResultCreator: 'chi^2': chi, 'R^2': r, 'AIC': loglikehood + 2 * nvar, - 'BIC': loglikehood + np.log(nobs) * nvar + 'BIC': loglikehood + np.log(nobs) * nvar, + 'adj. R^2': 1 - (nobs-1) / (dof+1e-13) * (1-r), + 'red. chi^2': chi / (dof + 1e-13), } - if dof != 0: - stats['adj. R^2'] = 1 - (nobs-1)/dof * (1-r) - stats['red. chi^2'] = chi / dof if dof != 0 else 0 - - if dof != 1: - stats['AICc'] = stats['AIC'] + 2*(nvar+1)*nvar / (dof-1) + stats['AICc'] = stats['AIC'] + 2*(nvar+1)*nvar / (dof - 1 + 1e-13) return stats