Community
cancel
Showing results for 
Search instead for 
Did you mean: 
LWang77
Beginner
442 Views

MKL - General Polynomial Fitting function?

Hi,

I’m looking for a general Polynomial Fitting function in MKL, which is similar to Polyfit function from Matlab, OptiVec and Armadillo.  This function uses two set of input data X and Y to determine the coefficients ai of a polynomial:

P= a0 + a1Xi + a2Xi2 ... anXin

Where,

χ2 = sum( 1/σi2 * (Pi - Yi));

Is minimized.

I have searched MKL Data Fitting Library and found that all of routines are Spline-based.  In MKL LAPACK library, I found some routines the Least Squares ones.

I understand that,

  1. as the order of the polynomial increases, Spline-based methods are preferable over polynomial interpolation because its interpolation error increases
  2. when the number of points of X and Y > (1 + the degree) of the polynomial to be used, the Least Squares fit will be used

However, what I’m looking for is a general Polynomial Fitting function described above.  Is there such function in MKL?  Where can I find it in MKL (or IPP)?

0 Kudos
3 Replies
mecej4
Black Belt
442 Views

The Matlab polyfit routine is restricted to fitting with uniform weighting, i.e., σi is the same for all i. This capability is available in Lapack, in the subroutine ?GELS.

There is no ready-to-use-routine for the non-uniform weights case in MKL, as far as I know, but you should be able to put one together using the matrix manipulation routines that are available in BLAS/Lapack.

LWang77
Beginner
442 Views

Thank you for your advice, mecej4!

According to the MKL Reference, the function ?gels

Uses QR or LQ factorization to solve a overdetermined or underdetermined linear system with full rank matrix.

The uniform weighting is ok for our application.  In addition to the Least Squares fit, however, we are looking for Polynomial Fitting function that determine the coefficients of a polynomial for:

      Number of input points = (1 + degree) of the polynomial to be used

Is there such Polynomial Fitting function in MKL (or IPP)? In other words, we need to calculate the coefficients of a polynomial that neither overdetermined nor underdetermined.

mecej4
Black Belt
442 Views

The interpolating polynomial can be obtained in the Lagrange form explicitly, without any matrix algebra. See https://en.wikipedia.org/wiki/Lagrange_polynomial .

If the coefficients are desired, rather than interpolants, you may use the Lapack routine ?GESV, which is available in MKL.

Reply