Interpolation Question

import re from decimal import * import numpy from scipy.signal import cspline1d, cspline1d_eval import scipy.interpolate import scipy import math import numpy from scipy import interpolate Y1 =[0.48960000000000004, 0.52736099999999997, 0.56413900000000006, 0.60200199999999993, 0.64071400000000001, 0.67668399999999995, 0.71315899999999999, 0.75050499999999998, 0.61494199999999999, 0.66246900000000009] X1 =[0.024, 0.026000000000000002, 0.028000000000000004, 0.029999999999999999, 0.032000000000000001, 0.034000000000000002, 0.035999999999999997, 0.038000000000000006, 0.029999999999999999, 0.032500000000000001] rep = scipy.interpolate.splrep(X1,Y1) 

In the above code I get and error

 Traceback (most recent call last): File "/home/vibhor/Desktop/timing_tool/timing/interpolation_cap.py", line 64, in <module> rep = scipy.interpolate.splrep(X1,Y1) File "/usr/lib/python2.6/site-packages/scipy/interpolate/fitpack.py", line 418, in splrep raise _iermess[ier][1],_iermess[ier][0] ValueError: Error on input data 

I don’t know what is going on.

+6
python scipy
source share
2 answers

I believe that due to the fact that the values ​​of X1 are not ordered from smallest to largest, plus you have one repeating x-point, i.e. you need to sort the values ​​for X1 and Y1 before you can use splrep and remove duplicates.

The splrep from the docs seems to be low-level access to the FITPACK libraries, which expects a sorted, non-duplicate list, why it returns an error

interpolate.interp1d may seem to have worked, but were you really trying to use it to find a new point? I think you will find an error when you call it ie rep (2)

+10
source share

The value of X 0.02999999999999999999 occurs twice, with two different Y coordinates. This does not surprise me if this caused a problem, trying to fit a polynomial spline segment ....

+1
source share

All Articles