fit a polynomial to data - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Statistics : Statistics Package : Regression : Statistics/PolynomialFit

Statistics[PolynomialFit] - fit a polynomial to data

Calling Sequence

PolynomialFit(d, X, Y, v, options)

PolynomialFit(d, XY, v, options)




posint; degree of polynomial model function



Vector; values of independent variable



Vector; values of dependent variable



Matrix; values of independent and dependent variables



name; (optional) independent variable name



(optional) equation(s) of the form option=value where option is one of output, svdtolerance or weights; specify options for the PolynomialFit command



The PolynomialFit command fits a univariate polynomial to data by minimizing the least-squares error.  Consider a model polynomial px of independent variable x and a dependent variable y.  Given k data points, where each point is a pair of numerical values for x,y, this command finds coefficients of px such that the sum of the k residuals squared is minimized.  The ith residual is the value ypx at the ith data point.


The first parameter d is the degree of px.


In the first calling sequence, the second parameter X is a Vector containing the k values of the independent variable x, and the third parameter Y is a Vector containing the k values of the dependent variable y. In the second calling sequence XY is a Matrix with two columns, where the first column corresponds to X and the second column to Y. For X, Y, and XY, one can also use lists or Arrays; for details, see the Input Forms help page.


By default, the PolynomialFit command returns a Vector of dimension d+1 containing the coefficients of the polynomial resulting in the best fit, ordered from lowest to highest degree.  If the optional parameter v is provided, then a polynomial in this variable name is returned instead.


By default, either the least-squares polynomial or a Vector containing the parameter values is returned, depending on the input arguments. Additional results or a solution module that allows you to query for various settings and results can be obtained with the output option.  For more information, see the Statistics/Regression/Solution help page.


Weights for the data points can be supplied through the weights option.



The options argument can contain one or more of the options shown below.  These options are described in more detail on the Statistics/Regression/Options help page.


output = name or string --  Specify the form of the solution.  The output option can take as a value the name solutionmodule, or one of the following names (or a list of these names): AtkinsonTstatistic, confidenceintervals, CookDstatistic, degreesoffreedom, externallystandardizedresiduals, internallystandardizedresiduals, leastsquaresfunction, leverages, parametervalues, parametervector, residuals, residualmeansquare, residualstandarddeviation, residualsumofsquares, standarderrors, variancecovariancematrix. For more information, see the Statistics/Regression/Solution help page.


svdtolerance = realcons(nonnegative) -- Set the tolerance that determines whether a singular-value decomposition is performed.


weights = Vector -- Provide weights for the data points.



The underlying computation is done in floating-point; therefore, all data points must have type realcons and all returned solutions are floating-point, even if the problem is specified with exact values.  For more information about numeric computation in the Statistics package, see the Statistics/Computation help page.


The PolynomialFit command uses various methods implemented in a built-in library provided by the Numerical Algorithms Group (NAG).  Normally, a method using QR decomposition is applied.  If it is determined that the system does not have full rank, then a singular-value decomposition (SVD) is performed. The svdtolerance option allows you to specify when an SVD should be performed.  See the Statistics/Regression/Options help page for additional details.











Use the output=solutionmodule option to see the full results.


m:=moduleexportResults,Settings;end module





See Also

CurveFitting, Statistics, Statistics/Computation, Statistics/Regression, Statistics/Regression/InputForms, Statistics/Regression/Options, Statistics/Regression/Solution

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