Satimage Previous | Next
Fitting an array of real
Home Documentation Smile Computing Smile's maths Fitting an array of real  
Given two arrays of real x and y you can get the best polynomial fit y=P(x) with fitpolynomial.

You specify the degree of the polynom. The result returned contains, as a record:
fit error
fit result
the list of the coefficients (zero degree first)
fit string
a string suitable, either to display the equation of the polynom, or to provide this equation as a formula to the objects which accept formulae, such as the curves.
set rnds to randomarray 20 range {0, 1}
set x to runningsum rnds
set y to runningsum x
set c_data to QuickCurve(x, y, 0)
set v to c_data's container
set {fit string:the_formula} to fitpolynomial {x, y} degree 2
set c_fit to QuickCurve(x, the_formula, v)
set v's name to the_formula
draw v's container


Import script
Version française
Copyright ©2008 Paris, Satimage