FitLine
The FitLine 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 = FitLine( x[], y[] ) CLsqFit = FitLine( x[], y[], w[] ) 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. CLsqFit is a CLsqFit object containing the fit properties and results. |
This example fits x and y tables of numbers:
|
-- x data |
|
-- y data |
|
-- Fit the line, return a CLsqFit object |
|
-- 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 |