How to perform cubic spline interpolation in python?

Short answer: from scipy import interpolate def f(x): x_points = [ 0, 1, 2, 3, 4, 5] y_points = [12,14,22,39,58,77] tck = interpolate.splrep(x_points, y_points) return interpolate.splev(x, tck) print(f(1.25)) Long answer: scipy separates the steps involved in spline interpolation into two operations, most likely for computational efficiency. The coefficients describing the spline curve are computed, using … Read more