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)

Parameters

xydata

-

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

xdata

-

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

ydata

-

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

v

-

name; independent variable

opts

-

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

Description

• 

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](..).

Examples

withCurveFitting:

LeastSquares0,1,1,2,2,3,3,10,v

15+145v

(1)

LeastSquares0,1,2,3,1,2,3,10,v,weight=1,1,1,10

4773+25373v

(2)

LeastSquares0,1,3,5,6,2,1,3,6,8,v,curve=av2+bv+c

48727333091v+1721v2

(3)

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