void LnFit(TVec B, TVec X, TVec Y, TVec Weights)
Fits simple logarithm equation y(x)=b[0] + b[1]*ln(x) to data.
| # | Name | Description |
|---|---|---|
| 1 | X | Vector of independent variable. |
| 2 | Y | Vector of dependent variable. |
| 3 | Weights | Weights (optional). Weights are used only if they are set. |
| 4 | B | Returns 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:
Examples
using Dew.Math;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example(Steema.TeeChart.Styles.Line line1,
Steema.TeeChart.Styles.Line line2)
{
Vector X = new Vector(100);
Vector Y = new Vector(100);
Vector B = new Vector(0);
Vector YHat = new Vector(0);
X.Ramp(0.5, 0.05); // x= 0.5, 0.55, ...
Y.RandGauss(3.5, 0.12); // sample data
// calculate coefficients
RegModels.LnFit(B,X,Y,null);
// evaluate y by using calculated coefficients
RegModels.LnEval(B,X, YHat);
MtxVecTee.DrawValues(X,Y,line1,false);
MtxVecTee.DrawValues(X,YHat,line2,false);
}
}
See Also: RegModels.LnEval