using numpy.polynomial.hermite.hermfit in python for curve fitting to data?

625 Views Asked by At

I need some help understanding this numpy function called "numpy.polynomial.hermite.hermfit(x, y, deg, rcond=None, full=False, w=None)":https://numpy.org/doc/stable/reference/generated/numpy.polynomial.hermite.hermfit.html#numpy.polynomial.hermite.hermfit

It says in the documentation that it takes data and does a fitting to Gauss-Hermite polynomial and then gives the values of the coefficients. I want to know the following:

  1. What is the actual expression of the Gauss-Hermite polynomial they are fitting the data to?
  2. The documents states that the coefficients are returned according to the degree that is input into the function. Does this mean that if deg=2, the returned answers are h1 and h2? or if deg=4, they are h1,h2,h3,h4? The worked example in the doc doesn't explicitly state that.

Thanks lots.

1

There are 1 best solutions below

3
Jakob Stark On

The Hermite polynomials are a series of polynomials. It can be used similar as for example Taylor polynoms in a Taylor series for approximating a function. On wikipedia you can also find a list of the exact expressions (numpy uses the "physicist's" definition of the Hermite polynomials).

The function returns the coefficients of the hermite series expansion. So for example in a fit with degree 3 the series expression is

c0*H0 + c1*H1 + c2*H2

and the fit function returns the list

[c0,c1,c2]

You can pass this list to the np.polynomial.hermite.hermval function to evaluate the whole expression.