void PowerFit(TVec *B, TVec *X, TVec *Y, TVec *Weights = null);
Fits simple exponential equation to data.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | B | TVec * | Returns regression coefficients for power function. |
| 2 | X | TVec * | Vector of independent variable. |
| 3 | Y | TVec * | Vector of dependent variable. |
| 4 | Weights = null | TVec * | Weights (optional). Weights are used only if they are set. |
Remarks:
The routine fits equations to data by minimizing the sum of squared residuals. The observed values obey the following equation:
Examples
#include "MtxExpr.h"
#include "Units.RegModels.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Stats::Units::RegModels;
void Example()
{
Vector X(100,false);
Vector Y(0);
Vector YHat(0);
Vector B(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
PowerFit(B,X,Y,nullptr); // calculate coefficients
// evaluate y
PowerEval(B, X, YHat);
}
See Also: RegModels::PowerDeriv, RegModels::PowerEval
Declared in Dew::Stats::Units::RegModels · Dew.Stats/Units.RegModels.h · Cross-compiler