RegModels.LnFit Method

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

Fits simple logarithm equation y(x)=b[0] + b[1]*ln(x) 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 natural logarithm 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]+b[1]ln(x)Y = b[0] + b[1] \ln(x)
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(0.5, 0.05); // x= 0.5, 0.55, ...
    Y.RandGauss(3.5,0.12); // populate sample data
    LnFit(B,X,Y); // calculate coefficients
    LnEval(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.LnEval