From 294a22d4366696156c372fb480822b483c5e6d1d Mon Sep 17 00:00:00 2001 From: Drew Date: Fri, 1 Jul 2022 18:47:29 -0400 Subject: [PATCH] fitting (linear): fix indexing The linear fitting function used 1-indexed array notation instead of the Python-default 0-indexing. We discovered this by ending up with a divide-by-zero error when our x-values were roughly set to [0, 1], so the two 1 values were subtracted from each other. --- oitg/fitting/line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oitg/fitting/line.py b/oitg/fitting/line.py index 57daa4b..6f0614d 100755 --- a/oitg/fitting/line.py +++ b/oitg/fitting/line.py @@ -4,8 +4,8 @@ from . import FitBase def parameter_initialiser(x, y, p): - k = (y[-1] - y[1]) / (x[-1] - x[1]) - p['a'] = y[1] - x[1] * k + k = (y[-1] - y[0]) / (x[-1] - x[0]) + p['a'] = y[0] - x[0] * k p['b'] = k def fitting_function(x, p):