Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k 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.

w=1.25

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)

print(f(1.25))

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
4 answers
0 votes
1 answer
asked Jul 18, 2019 in Python by Sammy (47.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...