FitPoly
The FitPoly function fits a line to 2 tables containing x values and y values. This method creates a CLsqFit object, providing full access to all aspects of the fit.
CLsqFit = FitPoly( x[], y[], nCoefs ) CLsqFit = FitPoly( x[], y[], w[], nCoefs ) where x[] is a lua table containing the x values. y[] is a lua table containing the y values (observations). w[] is an optional lua table containing the weight values. nCoefs is the number of coefficients, between 1 and 10. CLsqFit is a CLsqFit object containing the fit properties and results. |
This example fits x and y tables to y = a[1] + a[2]x + a[3]x^2 + a[4]x^3:
|
-- x data |
|
-- y data |
|
-- Fit a polyniomial of 4 terms. |
|
-- if fit was not successful, then... |
|
-- get the error channel |
|
-- get the error message |
|
-- exit the script and list the error message |
|
|
|
-- list the standard deviation of the fit |
|
-- do other things with the fit |