Skip to content

Commit

Permalink
polyfit reference for linearity fit
Browse files Browse the repository at this point in the history
  • Loading branch information
fariza committed Sep 23, 2016
1 parent 553209a commit 46785cb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions emva1288/process/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,10 @@ def linearity(self):
##################################################################
# Following the emva1288 standart for the computation of the fit #
##################################################################

X_ = X[imin: imax]
Y_ = Y[imin: imax]

xy = np.sum(X_ / Y_)
xy2 = np.sum(X_ / (Y_ ** 2))
x2y2 = np.sum((X_ / Y_) ** 2)
Expand All @@ -571,6 +573,9 @@ def linearity(self):
b = ((xy * xy2) - (x2y2 * _y)) / ((xy2 ** 2) - (x2y2 * _y2))
a = (xy - (b * xy2)) / x2y2

# The equivalent numpy polyfit is
# a, b = np.polynomial.polynomial.polyfit(X_, Y_, 1, w=1 / Y_)

dev = 100. * (Y - (a * X + b)) / (a * X + b)

lin = {}
Expand Down

0 comments on commit 46785cb

Please sign in to comment.