0
0
SciPydata~10 mins

Parametric 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 parametric spline function from scipy.

SciPy
from scipy.interpolate import [1]
Drag options to blanks, or click blank then click option'
AUnivariateSpline
Bsplprep
Cgriddata
Dinterp1d
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing interpolation functions meant for 1D data like interp1d.
Confusing griddata with parametric spline functions.
2fill in blank
medium

Complete the code to create a parametric spline representation of points x and y.

SciPy
tck, u = splprep([x, y], s=[1])
Drag options to blanks, or click blank then click option'
A0
B1
CNone
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or negative values for smoothing which are invalid here.
Using smoothing > 0 which allows approximation, not exact fit.
3fill in blank
hard

Fix the error in the code to evaluate the spline at new parameter values u_new.

SciPy
x_new, y_new = splev([1], tck)
Drag options to blanks, or click blank then click option'
Au_new
Btck
Cx
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the spline representation tck as the first argument instead of the parameter values.
Passing original data points instead of parameter values.
4fill in blank
hard

Fill both blanks to create a smooth parametric curve and evaluate it at 100 points.

SciPy
tck, u = splprep([x, y], s=[1])
u_new = np.linspace(0, 1, [2])
Drag options to blanks, or click blank then click option'
A0
B50
C100
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using smoothing > 0 which approximates instead of fitting exactly.
Choosing too few points for evaluation leading to a rough curve.
5fill in blank
hard

Fill all three blanks to create a parametric spline, evaluate it, and plot the smooth curve.

SciPy
tck, u = splprep([x, y], s=[1])
u_new = np.linspace(0, 1, [2])
x_new, y_new = splev([3], tck)
plt.plot(x_new, y_new)
plt.show()
Drag options to blanks, or click blank then click option'
A0
B50
Cu_new
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable for evaluation in splev.
Choosing smoothing > 0 which changes the curve shape.