void PowerFit(TVec B, TVec X, TVec Y, TVec Weights)
Fits simple exponential equation 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 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:
Examples
using Dew.Math;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example(Steema.TeeChart.Styles.Point series1,
Steema.TeeChart.Styles.Point series 2)
{
Vector X = new Vector(100,false);
Vector Y = new Vector(0);
Vector YHat = new Vector(0);
Vector B = new Vector(0);
X.Ramp(-5.0, 0.1); // x= -5.0, -4.9, ..., +4.9
Y.Size(X);
Y.RandGauss(3.5,0.1); // sample data
RegModels.PowerFit(B,X,Y,null); // calculate coefficients
// evaluate y
RegModels.PowerEval(B, X, YHat);
MtxVecTee.DrawValues(X,Y,series1,false); // original data
MtxVecTee.DrawValueS(X,YHat,series2,false); // fitted data
}
}
See Also: RegModels.PowerDeriv, RegModels.PowerEval