ScrenPanel6

This commit is contained in:
root
2020-02-07 11:43:37 +01:00
parent 7f88d445af
commit f957ab5cb8
63 changed files with 12762 additions and 382 deletions

16
script/CPython/linfit.py Normal file
View File

@@ -0,0 +1,16 @@
import numpy as np
def linfit(x, y):
"""
Return linear fit
"""
p = np.polyfit(x, y, 1)
f = np.poly1d(p)
x_fit = np.linspace(min(x), max(x), 100)
y_fit = f(x_fit)
yhat = f(x)
ybar = np.sum(y)/len(y)
ssreg = np.sum((yhat - ybar)**2)
sstot = np.sum((y - ybar)**2)
R2 = ssreg / sstot
return (p, x_fit, y_fit, R2)

View File

@@ -12,6 +12,10 @@ def gfitoff(x, y, off=None, amp=None, com=None, sigma=None):
ret = call_jep("CPython/gfitoff", "gfitoff", [to_npa(x), to_npa(y), off, amp, com, sigma])
return ret if ret is None or is_list(ret) else ret.data
def linfit(x, y):
ret = call_jep("CPython/linfit", "linfit", [to_npa(x),to_npa(y)])
return (ret[0].data, ret[1].data, ret[2].data, ret[3])