Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (12.7k points)

Consider I have two lists, for describing the function y(x):

x = [0,1,2,3,4,5]

y = [12,14,22,39,58,77]

To give some value 'w' in the domain of x, I'm going to perform cubic spline interpolation.


I can find y(w)

I found this through Scipy, But I don't know how to use it.

python scipy interpolation spline cubic-spline

1 Answer

0 votes
by (26.4k points)

Look at the following code,

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)


Want to learn more topics related to Python? Come & join: Python training course

To know more about python, do check out:

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 18, 2019 in Python by Sammy (47.6k points)

Browse Categories