본문으로 바로가기

Interpolation 예제 - UnivariateSpline

category CAE/Enjoy Programming 2012. 1. 15. 05:58

from numpy import linspace,exp

from numpy.random import randn

from scipy.interpolate import UnivariateSpline

import matplotlib.pyplot as plt

x=linspace(-3,3,100)
y=exp(-x **2)+randn(100)/10

s=UnivariateSpline(x, y, s=1)

xs=linspace(-3,3,1000)
ys=s(xs)

plt.plot(x, y)
plt.plot(xs, ys)
plt.show()