def rss(d, p, pf, f):
     #y = fnc.fv(cubic_spline_fit.fn, d[:,0], p, pf)
     #rss_v = 0.0
     #for i in range(len(d[:,0])):
     #  if(d[i,0] < 1.0):
     #    rss_v = rss_v + (y[i] - d[i,1])**2
     #  elif(d[i,0] < 1.5):
     #    rss_v = rss_v + (abs(y[i] - d[i,1]))**3
     #  else:
     #    rss_v = rss_v + (abs(y[i] - d[i,1]))**4
     #return rss_v
     y = fnc.fv(cubic_spline_fit.fn, d[:, 0], p, pf)
     return sum((y[:] - d[:, 1])**2)
from f_fnc import fnc
import numpy
import matplotlib.pyplot as plt

p = numpy.asarray([0.01, 0.0, -0.01, 0.0])
pf = numpy.asarray([2.0, 3.0, 4.0, 5.0, 26.0, 26.0, 0.8, 1.8, 1])

x = numpy.linspace(0.0, 7.0, 1001)
y = fnc.fv("cubic_spline_zbl", x, p, pf)

plt.plot(x, y, 'k')
plt.ylim(-5.0, 10.0)
plt.show()
Exemple #3
0
 def fv(x, p, pf):
   return fnc.fv(test.fn, x, p, pf)
 def fv(x, p, pf):
     return fnc.fv(cubic_spline_fit.fn, x, p, pf)
 def rss_opt(p):
     y = fnc.fv(cubic_spline_fit.fn, cubic_spline_fit.d[:, 0], p,
                cubic_spline_fit.pf)
     return sum((y[:] - cubic_spline_fit.d[:, 1])**2)