LinearRegression struct
Perform a simple linear regression to predict values with a linear model.
Constructors, destructors, conversion operators
- LinearRegression(std::vector<double> const& in_x, std::vector<double> const& in_y)
- Construct a linear regression.
Public functions
- void compute()
- Perform the regression.
- auto getSlope() const -> double
- Get the slope.
- auto getIntercept() const -> double
- Get the y-intercept.
- auto predict(double in_x) -> double
- Predict a value using the linear model.
Function documentation
vt:: util:: stats:: LinearRegression:: LinearRegression(std::vector<double> const& in_x,
std::vector<double> const& in_y)
Construct a linear regression.
| Parameters | |
|---|---|
| in_x in | the x-values |
| in_y in | the y-values |
double vt:: util:: stats:: LinearRegression:: getSlope() const
Get the slope.
| Returns | the slope of the line |
|---|
double vt:: util:: stats:: LinearRegression:: getIntercept() const
Get the y-intercept.
| Returns | the y-intercept |
|---|
double vt:: util:: stats:: LinearRegression:: predict(double in_x)
Predict a value using the linear model.
| Parameters | |
|---|---|
| in_x in | the x value to predict |
| Returns | the y value |