RegModels.PowerFit Method

procedure PowerFit(const B: TVec; const X: TVec; const Y: TVec; const Weights: TVec);

Fits simple exponential equation to data.

#NameDescription
1XVector of independent variable.
2YVector of dependent variable.
3WeightsWeights (optional). Weights are used only if they are set.
4BReturns regression coefficients for power function.

Result: stored in self (calling object)

Remarks:

The routine fits equations to data by minimizing the sum of squared residuals. The observed values obey the following equation:

Y=b[0]Xb[1].Y=b[0] X^{b[1]} \quad .
Examples
Uses MathExpr, MtxVecTee, Series, RegModels;
procedure Example(Series1: TLineSeries);
var Y,YHat,B,X: Vector;
begin
    X.Size(100);
    Y.Size(X);
    X.Ramp(-5,0.05); // X = (-5, -4.95, ...-0.05)
    Y.RandGauss(3.5,0.12); // populate sample data
    PowerFit(B,X,Y); // calculate coefficients
    // evaluate y by using calculated coefficients
    PowerEval(B,X,YHat);
    DrawValues(X,Y,Series1); // draw original data
    DrawValues(X,YHat,Series2); // draw fitted data
end;
See Also: RegModels.PowerDeriv, RegModels.PowerEval