Startup
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
def extremum(x, y):
|
||||
"""
|
||||
Return extremum coordinates of quadratic fit
|
||||
"""
|
||||
pf = np.polyfit(x, y, 2, full=True)
|
||||
p = pf[0]
|
||||
res = pf[1][0]
|
||||
p = np.polyfit(x, y, 2)
|
||||
f = np.poly1d(p)
|
||||
if p[0] != 0:
|
||||
x_ext = -p[1] / (2 * p[0])
|
||||
@@ -15,6 +12,11 @@ def extremum(x, y):
|
||||
else:
|
||||
x_ext = None
|
||||
y_ext = None
|
||||
yhat = f(x)
|
||||
ybar = np.sum(y)/len(y)
|
||||
ssreg = np.sum((yhat - ybar)**2)
|
||||
sstot = np.sum((y - ybar)**2)
|
||||
R2 = ssreg / sstot
|
||||
x_fit = np.linspace(min(x), max(x), 100)
|
||||
y_fit = f(x_fit)
|
||||
return (x_ext, y_ext, x_fit, y_fit, res)
|
||||
return (x_ext, y_ext, x_fit, y_fit, R2)
|
||||
|
||||
Reference in New Issue
Block a user