Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure PolyFit(XValues: TVec; YValues: TVec; Degree: Integer; Coeff: TVec; R: TMtx; out DegFreedom: Integer; out L2R: Double; Weights: TVec); | Fits a polynomial to data. |
| 2 | procedure PolyFit(XValues: TVec; YValues: TVec; Degree: Integer; Coeff: TVec; Weights: TVec); | Fits a polynomial to data. |
Overload 1: procedure PolyFit(XValues: TVec; YValues: TVec; Degree: Integer; Coeff: TVec; R: TMtx; out DegFreedom: Integer; out L2R: Double; Weights: TVec);
Fits a polynomial to data.
| # | Name | Description |
|---|---|---|
| 1 | XValues | Defines x values in p=p(x). |
| 2 | YValues | Defines polynomial, evaluated at x i.e p(x). |
| 3 | Degree | Defines polynomial degree. |
| 4 | Weights | If not nil, defines fitting weights. |
| 5 | Coeff | Returns the coeficients of fitted polynomial. |
| 6 | R | Returns the Cholesky factor of the Vandermonde matrix. |
| 7 | DegFreedom | Returns the degree of freedom. |
| 8 | L2R | Returns the L2 norm of the residuals. |
Result: stored in self (calling object)
Remarks:
The PolyFit procedure uses the least-squares method to find the fitted polynomial coefficients.
Examples
uses MtxExpr, Math387, MtxVec, MtxVecTee, Polynoms;
procedure TForm1.Button1Click(Sender: TObject);
var X,Y,YCalc,Delta,Coeff: Vector;
R: Matrix;
DegF: Integer;
L2R : double;
begin
X.Size(100,false);
Y.Size(X);
X.Ramp;
Y.RandGauss(2,3);
PolyFit(X,Y,3,Coeff,R,DegF,L2R); //Fit
PolyEval(X,Coeff,R,DegF,L2R,YCalc,Delta); // evaluate
DrawIt([Y,YCalc],['Original','Polyfit']);
end;
Overload 2: procedure PolyFit(XValues: TVec; YValues: TVec; Degree: Integer; Coeff: TVec; Weights: TVec);
Fits a polynomial to data.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | XValues | TVec | source TVec |
| 2 | YValues | TVec | source TVec |
| 3 | Degree | Integer | |
| 4 | Coeff | TVec | source TVec |
| 5 | Weights | TVec | source TVec |
Result: stored in self (calling object)
Remarks:
This overload does not return additional statistical parameters like Cholesky matrix or degrees of freedom.