compute a least-squares approximation - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Numerical Computations : Interpolation and Curve Fitting : CurveFitting Package : CurveFitting/LeastSquares

CurveFitting[LeastSquares] - compute a least-squares approximation

Calling Sequence

LeastSquares(xydata, v, opts)

LeastSquares(xdata, ydata, v, opts)




Array, Matrix, or list of the form [[x1,y1], [x2,y2], ..., [xn,yn]]; data points



Array, Vector, or list of the form [x1, x2, ..., xn]; independent values



Array, Vector, or list of the form [y1, y2, ..., yn]; dependent values



name; independent variable



(optional) one or more equations of the form weight=wlist, curve=f or params=pset



The LeastSquares routine computes a least-squares approximation to the points {x1,y1,x2,y2,...,xn,yn}.  A linear function in variable v is returned unless the curve=f option is provided.


The LeastSquares procedure can be called in two ways.


The first form accepts a list, Array, or Matrix, [[x1,y1],[x2,y2],...,[xn,yn]], of data points.


The second form accepts this input data as two lists, two Arrays, or two Vectors. In this form, the first set of data contains the independent values, [x1,x2,...,xn], and the second set of data contains the dependent values, [y1,y2,...,yn].  Each element must be of type algebraic.


The default function that is returned has the form av+b.  A different function to fit the data points can be specified by using the curve=f option.  The function fv must be linear in the unknown parameters, though f itself need not be linear. For example, the function av2+bv+c is acceptable as it is linear in parameters a, b and c.


If the curve=f option is given, the params=pset option can be used, where pset is a set of the unknown parameters.  If the params option is not provided, then the unknown parameters are the indeterminates in f different from v.


A weight can be assigned to each data point by using the weight=wlist option, where wlist is a list containing exactly n non-negative values.


If a unique solution cannot be determined from the input data, then a parametrized solution that uses automatically generated parameter names is returned.


More extensive least-squares fitting functionality, including nonlinear fitting, is available in the Statistics package.  For more information, see the Statistics/Regression help page.


This function is part of the CurveFitting package, and so it can be used in the form LeastSquares(..) only after executing the command with(CurveFitting).  However, it can always be accessed through the long form of the command by using CurveFitting[LeastSquares](..).












See Also

CurveFitting, Statistics, Statistics/Regression, type/algebraic

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam