RegModels.ExpFit Method

procedure ExpFit(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 simple exponent 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]exp(b[1]X).Y=b[0]\cdot \exp \left(b[1]\cdot X\right) \quad .
Examples
Uses MtxExpr, MtxVecTee, Series, RegModels;
procedure Example(Series1, Series2: 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
    ExpFit(B,X,Y); // calculate coefficients
    ExpEval(B.Values,X,YHat); // evaluate y by using calculated coefficients
    DrawValues(X,Y,Series1); // draw original data
    DrawValues(X,YHat,Series2); // draw fitted data
end;
See Also: RegModels.ExpDeriv, RegModels.ExpEval