With the help of np.hermfit()
method, we can get the least square fits of hermite series by using np.hermfit()
method.
Syntax :
np.hermfit(x, y, deg)
Return : Return the least square fits of hermite series.
Example #1 :
In this example we can see that by using np.hermfit()
method, we are able to get the least square fits of hermite series of given data by using this method.
# import numpy and hermfit import numpy as np
from numpy.polynomial.hermite import hermfit
x = np.array([ - 3 , - 2 , - 1 ])
y = np.array([ 1 , 2 , 3 ])
deg = 2
# using np.hermfit() method gfg = hermfit(x, y, deg)
print (gfg)
|
Output :
[4.00000000e+00 5.00000000e-01 1.56777498e-16]
Example #2 :
# import numpy and hermfit import numpy as np
from numpy.polynomial.hermite import hermfit
x = np.array([ - 2 , - 1 , 0 , 1 , 2 ])
y = np.array([ 0.1 , 0.2 , 0.3 , 0.4 , 0.5 ])
deg = 3
# using np.hermfit() method gfg = hermfit(x, y, deg)
print (gfg)
|
Output :
[ 3.00000000e-01 5.00000000e-02 2.76178300e-18 -1.46465661e-18]