예제 #1
0
 def fit_quad(data_x, data_y):
     """
     4 次方程式で fit
     """
     def func(coefs, x):
         return (coefs[0] + coefs[1]*x + coefs[2]*(x**2) +
                 coefs[3]*(x**3) + coefs[4]*(x**4))
     opt_coefs, err = FitData.fit_arbfunc(data_x, data_y, func, [1, 1, 1, 1, 1])
     fitx = np.linspace(0, 1, 100)
     fity = func(opt_coefs, fitx)
     return opt_coefs, err, fitx, fity
예제 #2
0
 def fit_penta(data_x, data_y):
     """
     5 次方程式で fit
     両端は 0 に fix する
     """
     def func(coefs, x):
         return (coefs[0]*x + coefs[1]*(x**2) +
                 coefs[2]*(x**3) + coefs[3]*(x**4) +
                 (0 - sum(coefs))*(x**5))
     opt_coefs, err = FitData.fit_arbfunc(data_x, data_y, func, [1, 1, 1, 1])
     fitx = np.linspace(0, 1, 101)
     fity = func(opt_coefs, fitx)
     return opt_coefs, err, fitx, fity