def test_rmtb(self):
import numpy as np
import matplotlib.pyplot as plt
from smt.methods import RMTB
xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])
xlimits = np.array([[0., 4.]])
sm = RMTB(xlimits=xlimits, order=4, num_ctrl_pts=20, energy_weight=1e-15, regularization_weight=0.)
sm.set_training_values(xt, yt)
sm.train()
num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)
plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.legend(['Training data', 'Prediction'])
plt.show()
评论列表
文章目录