Google News
logo
SciPy - Interview Questions
What is Interpolation in SciPy?
SciPy Interpolation is defined as finding a value between two points on a line or a curve. The first part of the word is "inter" as meaning "enter", which indicates us to look inside the data. In the other words, "The estimation of intermediate value between the precise data points is called as interpolation". Interpolation is very useful in statistics, science, and business or when there is a need to predict the value that exists within two existing data points.
 
Let's have a look how the interpolation work using the scipy.interpolation package.

import numpy as np
from scipy import interpolate
import matplotlib.pyplot as plt
x = np.linspace(0, 4, 12)
y = np.cos(x**2/3+4)
print (x,y)​


Output :

(
   array([0.,  0.36363636,  0.72727273,  1.09090909,  1.45454545, 1.81818182, 
          2.18181818,  2.54545455,  2.90909091,  3.27272727,  3.63636364,  4.]),   

   array([-0.65364362,  -0.61966189,  -0.51077021,  -0.31047698,  -0.00715476,
            0.37976236,   0.76715099,   0.99239518,   0.85886263,   0.27994201,
           -0.52586509,  -0.99582185])
)

 

Advertisement