Open In App

Python | Numpy np.hermefit() method

Last Updated : 11 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

With the help of np.hermefit() method, we can get the least square fit of hermite series by using np.hermefit() method.

Syntax : np.hermefit(x, y, deg)
Return : Return the least square fit of given data.

Example #1 :
In this example we can see that by using np.hermefit() method, we are able to get the least square fit of hermite series by using this method.




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


Output :

[6.52513495e-15 -1.00000000e+00 3.34430164e-15 -4.02985428e-16]

Example #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)


Output :

[-1.00370716e-15 9.09090909e-02 -5.85610278e-19]


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads