Notice
Recent Posts
Recent Comments
Link
관리 메뉴

뛰는 놈 위에 나는 공대생

[데이터과학] scipy interpolation 종류 정리 본문

연구 Research/데이터과학 Data Science

[데이터과학] scipy interpolation 종류 정리

보통의공대생 2023. 8. 25. 18:06

모든 scipy interpolation을 다 시도해보았다.

각 interpolation마다 특징이 있으므로 원하는 것을 사용하면 된다.

 

from scipy import interpolate
import numpy as np
x = np.arange(0, 10)
y = np.sin(-x)
kind_set = [ "zero", "linear", "quadratic","nearest", "nearest-up", "slinear",  "cubic", "previous"]


xnew = np.arange(0, 9, 0.1)
for i in range(4):
    f = interpolate.interp1d(x, y, kind=kind_set[i])
    ynew = f(xnew)
    plt.plot(xnew, ynew, label=kind_set[i])
plt.plot(x,y,'o',label='origin')
plt.legend()
plt.show()

 

 

 

기본적으로 zero와 previous는 비슷하고

nearest는 x축에서 가까운 값을 사용한다. linear, cubic, quadratic, slinear는 이름이 말해주는 함수형태로 근사해서 interpolation을 수행한다.

Comments