Behavior Of Scipy's Splrep
I have a set of data points and would like to approximate them with a spline function. I used two different functions: splrep from scipy and a cubic spline function that I found h
Solution 1:
You need to define what you mean by "satisfying". Clearly, your cubic spline is not interpolating through the points, whereas the splrep
result does (and is perfectly satisfactory in that sense). Note also that your 'cubicspline' is actually just a single polynomial rather than a spline (which are polynomials with breakpoints).
You need to explicitly tell splrep
that the spline doesn't need to go through the points --- pass in a nonzero s
smoothing parameter. How to choose this properly, see this question:
scipy.interpolate.UnivariateSpline not smoothing regardless of parameters
Post a Comment for "Behavior Of Scipy's Splrep"