RegModels::ExpFit Function

void ExpFit(TVec *B, TVec *X, TVec *Y, TVec *Weights = null);

Fits simple exponential equation to data.

#NameTypeDescription
1BTVec *Returns regression coefficients for simple exponent function.
2XTVec *Vector of independent variable.
3YTVec *Vector of dependent variable.
4Weights = nullTVec *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:

Y=b[0]⋅exp⁡(b[1]⋅X).Y=b[0]\cdot \exp \left(b[1]\cdot X\right) \quad .
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);
    Vector Y(100);
    Vector B(0);
    Vector YHat(0);

    X.Ramp(-5.0, 0.05); // x= -5.0, -4.95, ... -0.05
    Y.RandGauss(3.5, 0.12); // sample data
    // calculate coefficients
    ExpFit(B,X,Y,nullptr);
    // evaluate y by using calculated coefficients
    ExpEval(B,X, YHat);
}
See Also: RegModels::ExpDeriv, RegModels::ExpEval
Declared in Dew::Stats::Units::RegModels · Dew.Stats/Units.RegModels.h · Cross-compiler