Python| Numpy np.hermefit() 方法
借助np.hermefit()
方法,我们可以使用np.hermefit()
方法得到 Hermite 级数的最小二乘拟合。
Syntax : np.hermefit(x, y, deg)
Return : Return the least square fit of given data.
示例 #1:
在这个例子中我们可以看到,通过使用np.hermefit()
方法,我们可以通过使用这个方法得到 Hermite 级数的最小二乘拟合。
# import numpy and hermefit
import numpy as np
from numpy.polynomial.hermite_e import hermefit
x = np.array([1, 2, 3, 4])
y = np.array([-1, -2, -3, -4])
deg = 3
# using np.hermefit() method
gfg = hermefit(x, y, deg)
print(gfg)
输出 :
[6.52513495e-15 -1.00000000e+00 3.34430164e-15 -4.02985428e-16]
示例 #2:
# import numpy and hermefit
import numpy as np
from numpy.polynomial.hermite_e import hermefit
x = np.array([11, 22, 33, 44])
y = np.array([1, 2, 3, 4])
deg = 2
# using np.hermefit() method
gfg = hermefit(x, y, deg)
print(gfg)
输出 :
[-1.00370716e-15 9.09090909e-02 -5.85610278e-19]