📜  Python| Numpy np.hermefit() 方法

📅  最后修改于: 2022-05-13 01:55:25.050000             🧑  作者: Mango

Python| Numpy np.hermefit() 方法

借助np.hermefit()方法,我们可以使用np.hermefit()方法得到 Hermite 级数的最小二乘拟合。

示例 #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)

输出 :

示例 #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)

输出 :