  # Python | Numpy np.hermefit () method

NumPy | Python Methods and Functions

With the `np.hermefit() ` method we can get the Hermite series least squares method using ` np.hermefit () `.

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

Example # 1:
In this example, we can see that using ` np.hermefit () ` we can get the least squares method for the Hermite series using this method.

 ` # NumPy and Hermefit imports ` ` 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 the 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:

 ` # NumPy and Hermefit imports ` ` 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 the np method. hermefit () ` ` gfg ` ` = ` ` hermefit ( x, y, deg) `   ` print ` ` (gfg) `

Output:

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