LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make sure the right order of the general Polynomial fit?

It is known to all that if the order of the general polynomial fit is to low, the fit result is too bad;if the order is too high, the fit can't fit well either.Then, how to determine the order of the general polynomial fit using labview 7.0?
0 Kudos
Message 1 of 12
(4,128 Views)
When using the General Polynomial Fit vi check the MSE terminal (Mean Square Errror)
Loop testing the MSE for better or worse MSE.

A nice mathmatical treatment of what you are tyring to do can be found here: -
http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/ch_fitt9.html

0 Kudos
Message 2 of 12
(4,122 Views)
Thanks.
Is there any example code written by labview?
0 Kudos
Message 3 of 12
(4,120 Views)

The attached example is based on the demonstration vi Regressions Demo.vi

Here the input data has been fixed so you can manually test various fit types and algorithims against one data set. I have tried to chose a data set that you can readily qualify yourself.

You will see that generally as you increase the number of orders the 'goodness of fit' indicated by the MSE value tends to decrease. As indicated in the previous hyper link there are alternative strategies which can give better results for different datatypes.

 

0 Kudos
Message 4 of 12
(4,109 Views)
But my labview version is 7.0, would you please save it to 7.0 for me?
Thanks very much!!
It seems that I should learn the basic theory of the fit goodness.
0 Kudos
Message 5 of 12
(4,099 Views)

Here is the example (re-written, as it would not save to previous version) for Labview 7.0

The 7.1 version attached previously was missing the data set, so if you want to try the example please bear this in mind (you can copy the data from the version 7.0 example to the 7.1 example or fill in your own).

0 Kudos
Message 6 of 12
(4,088 Views)
Another question: why does your vi use mse instead of

  to indicate a better fit??

0 Kudos
Message 7 of 12
(4,078 Views)

There are a number of different techniques for dermining the 'goodness of fit'.

The example shown is taken directly from the National Instruments (NI) example and is thier default measure. In most cases it's satisfactory, you are of course at liberty to implement your own measure by implementing your own code.

Take a look at the link provided, I think you will find it very informative.

0 Kudos
Message 8 of 12
(4,075 Views)
Thanks very much for your reply!
0 Kudos
Message 9 of 12
(4,072 Views)
Except for low polynomial orders, a polynomial fit is often used as a "generic fit" in the absence of a more precise mathematical model.  It provides a cosmetic fit to the data and the polynomial coefficients are relatively unimportant, because they don't have a physical meaning beyond describing and reproducing the general trend of the data.
 
To decide on the best polynomial order, you need to look at your data, including the estimated error of each data point. Graph your data on an xy graph and just look at it first!
  • If the relation between x any y is about linear within noise, only an order of 1 is appropriate, giving you the same result as linear regression.
  • If there is a slight banana in the data, a quadratic fit is probably sufficient.
  • If the data has positive and negative curvature, you need third order.
  • etc.

Try a few orders and look at the residual in a new x-y graph. Once there is no perceptible trend left in the residual, increasing the polynomial order would be meaningless.

Often, one polynomial coefficient is dominant. For example, the height of a dropping ball is mostly quadratic, but if measured over a huge range (e.g. dropped from a high flying airplane), you would need higher order terms to account for changes in air density, air resistance as a function of speed (laminar vs turbulent),  gravitiy as a function of height, etc. If you now want to describe the trajectory of a falling meteorite, it gets even more complex due to the evaporative loss in mass, for example. However, at one point in the analysis, a polynomial fit is no longer sufficient because all these terms might be described by a more precise theory that is not polynomial at all.

If you have a real physical process, you should fit with a model that has a theoretical foundation and makes sense! It would make no sense to e.g. fit an exponential decay with a polynomial, even if a 5th order polynomial looks very good. 😉 An exponential fit will give you the amplitude and damping factors, while a polynomial fit only gives you a buch of meaningless terms.

It is always best to fit to a real theoretical model if available. LabVIEW has all the tools to do it (Levenberg Marquardt, General LS fit, etc.). 😄

Good luck!

 

 

Message 10 of 12
(4,069 Views)