Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpolate Question

Tags:

python

scipy

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 am getting and error of

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

Don't know what is happening

like image 322
VASUDEVAN Avatar asked Jan 05 '10 21:01

VASUDEVAN


People also ask

What is an example of interpolate?

When you interject your opinion into a conversation that two other people are having, this is a time when you interpolate. When you insert words or letters into text, this is an example of a time when you interpolate.

What is an interpolation problem?

The interpolation problem for rational patches is often posed as the task of finding a rational patch that interpolates data points pi given in homogeneous coordinates pi = [wx wy wz w]Ti. As pointed out before, there is no good method to determine the weights a priori.

How do you interpolate in math?

interpolation, in mathematics, the determination or estimation of the value of f(x), or a function of x, from certain known values of the function. If x0 < … < xn and y0 = f(x0),…, yn = f(xn) are known, and if x0 < x < xn, then the estimated value of f(x) is said to be an interpolation.

What is interpolation answer?

In short, interpolation is a process of determining the unknown values that lie in between the known data points. It is mostly used to predict the unknown values for any geographical related data points such as noise level, rainfall, elevation, and so on.


2 Answers

I believe it's due to the X1 values not being ordered from smallest to largest plus also you have one duplicate x point, i.e, you need to sort the values for X1 and Y1 before you can use the splrep and remove duplicates.

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

interpolate.interp1d might seem to work, but have you actually tried to use it to find a new point? I think you'll find an error when you call it i.e. rep(2)

like image 128
petantik Avatar answered Sep 20 '22 22:09

petantik


The X value 0.029999999999999999 occurs twice, with two different Y coordinates. It wouldn't surprise me if that caused a problem trying to fit a polynomial spline segment....

like image 31
Jim Lewis Avatar answered Sep 20 '22 22:09

Jim Lewis