0
0
SciPydata~10 mins

interp1d for 1D interpolation in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the interpolation function from scipy.

SciPy
from scipy.interpolate import [1]
Drag options to blanks, or click blank then click option'
Ainterp1d
Binterpolate1d
Cinterp2d
Dinterpolate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'interpolate1d' which does not exist.
Confusing with 'interp2d' which is for 2D interpolation.
2fill in blank
medium

Complete the code to create an interpolation function for given x and y arrays.

SciPy
f = [1](x, y)
Drag options to blanks, or click blank then click option'
Ainterpolate1d
Binterp1d
Cinterp2d
Dinterpolate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'interp2d' which is for 2D interpolation.
Using 'interpolate' which is a module, not a function.
3fill in blank
hard

Fix the error in the code to evaluate the interpolation function at new points.

SciPy
y_new = f([1])
Drag options to blanks, or click blank then click option'
Ay_new
Bx
Cx_new
Df
Attempts:
3 left
💡 Hint
Common Mistakes
Passing y-values instead of x-values to the interpolation function.
Passing the function itself as argument.
4fill in blank
hard

Fill both blanks to create an interpolation function with linear method and evaluate it at new points.

SciPy
f = interp1d(x, y, kind=[1])
y_new = f([2])
Drag options to blanks, or click blank then click option'
A'linear'
Bx_new
C'nearest'
Dy_new
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'nearest' instead of 'linear' for the kind parameter.
Passing y_new instead of x_new to the function.
5fill in blank
hard

Fill all three blanks to create a cubic interpolation function, evaluate it at new points, and convert the result to a list.

SciPy
f = interp1d(x, y, kind=[1])
y_new = f([2])
y_list = [3](y_new)
Drag options to blanks, or click blank then click option'
A'cubic'
Bx_new
Clist
Darray
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'linear' or 'nearest' instead of 'cubic' for kind.
Not converting the result to a list.
Passing y_new instead of x_new to the function.