This class offers functions to perform least-squares fits to a straight line model, \( Y(c,x) = c_0 + c_1 x \).
More...
|
| LinearRegression () |
| Constructor. More...
|
|
virtual | ~LinearRegression ()=default |
| Destructor. More...
|
|
void | computeRegression (double confidence_interval_P, std::vector< double >::const_iterator x_begin, std::vector< double >::const_iterator x_end, std::vector< double >::const_iterator y_begin, bool compute_goodness=true) |
| This function computes the best-fit linear regression coefficients \( (c_0,c_1) \) of the model \( Y = c_0 + c_1 X \) for the dataset \( (x, y) \). More...
|
|
void | computeRegressionWeighted (double confidence_interval_P, std::vector< double >::const_iterator x_begin, std::vector< double >::const_iterator x_end, std::vector< double >::const_iterator y_begin, std::vector< double >::const_iterator w_begin, bool compute_goodness=true) |
| This function computes the best-fit linear regression coefficients \( (c_0,c_1) \) of the model \( Y = c_0 + c_1 X \) for the weighted dataset \( (x, y) \). More...
|
|
double | getIntercept () const |
| Non-mutable access to the y-intercept of the straight line. More...
|
|
double | getSlope () const |
| Non-mutable access to the slope of the straight line. More...
|
|
double | getXIntercept () const |
| Non-mutable access to the x-intercept of the straight line. More...
|
|
double | getLower () const |
| Non-mutable access to the lower border of confidence interval. More...
|
|
double | getUpper () const |
| Non-mutable access to the upper border of confidence interval. More...
|
|
double | getTValue () const |
| Non-mutable access to the value of the t-distribution. More...
|
|
double | getRSquared () const |
| Non-mutable access to the squared Pearson coefficient. More...
|
|
double | getStandDevRes () const |
| Non-mutable access to the standard deviation of the residuals. More...
|
|
double | getMeanRes () const |
| Non-mutable access to the residual mean. More...
|
|
double | getStandErrSlope () const |
| Non-mutable access to the standard error of the slope. More...
|
|
double | getChiSquared () const |
| Non-mutable access to the chi squared value. More...
|
|
double | getRSD () const |
| Non-mutable access to relative standard deviation. More...
|
|
|
void | computeGoodness_ (const std::vector< double > &X, const std::vector< double > &Y, double confidence_interval_P) |
| Computes the goodness of the fitted regression line. More...
|
|
template<typename Iterator > |
double | computeChiSquare (Iterator x_begin, Iterator x_end, Iterator y_begin, double slope, double intercept) |
| Compute the chi squared of a linear fit. More...
|
|
template<typename Iterator > |
double | computeWeightedChiSquare (Iterator x_begin, Iterator x_end, Iterator y_begin, Iterator w_begin, double slope, double intercept) |
| Compute the chi squared of a weighted linear fit. More...
|
|
This class offers functions to perform least-squares fits to a straight line model, \( Y(c,x) = c_0 + c_1 x \).
Next to the intercept with the y-axis and the slope of the fitted line, this class computes the:
- squared Pearson coefficient
- value of the t-distribution
- standard deviation of the residuals
- standard error of the slope
- intercept with the x-axis (useful for additive series experiments)
- lower border of confidence interval
- higher border of confidence interval
- chi squared value
- x mean
void computeRegression |
( |
double |
confidence_interval_P, |
|
|
std::vector< double >::const_iterator |
x_begin, |
|
|
std::vector< double >::const_iterator |
x_end, |
|
|
std::vector< double >::const_iterator |
y_begin, |
|
|
bool |
compute_goodness = true |
|
) |
| |
This function computes the best-fit linear regression coefficients \( (c_0,c_1) \) of the model \( Y = c_0 + c_1 X \) for the dataset \( (x, y) \).
The values in x-dimension of the dataset \( (x,y) \) are given by the iterator range [x_begin,x_end) and the corresponding y-values start at position y_begin.
For a "x %" Confidence Interval use confidence_interval_P = x/100. For example the 95% Confidence Interval is supposed to be an interval that has a 95% chance of containing the true value of the parameter.
- Parameters
-
confidence_interval_P | Value between 0-1 to determine lower and upper CI borders. |
x_begin | Begin iterator of x values |
x_end | End iterator of x values |
y_begin | Begin iterator of y values (same length as x) |
compute_goodness | Compute meta stats about the fit. If this is not done, none of the members (except slope and intercept) are meaningful. |
- Exceptions
-
void computeRegressionWeighted |
( |
double |
confidence_interval_P, |
|
|
std::vector< double >::const_iterator |
x_begin, |
|
|
std::vector< double >::const_iterator |
x_end, |
|
|
std::vector< double >::const_iterator |
y_begin, |
|
|
std::vector< double >::const_iterator |
w_begin, |
|
|
bool |
compute_goodness = true |
|
) |
| |
This function computes the best-fit linear regression coefficients \( (c_0,c_1) \) of the model \( Y = c_0 + c_1 X \) for the weighted dataset \( (x, y) \).
The values in x-dimension of the dataset \( (x, y) \) are given by the iterator range [x_begin,x_end) and the corresponding y-values start at position y_begin. They will be weighted by the values starting at w_begin.
For a "x %" Confidence Interval use confidence_interval_P = x/100. For example the 95% Confidence Interval is supposed to be an interval that has a 95% chance of containing the true value of the parameter.
- Parameters
-
confidence_interval_P | Value between 0-1 to determine lower and upper CI borders. |
x_begin | Begin iterator of x values |
x_end | End iterator of x values |
y_begin | Begin iterator of y values (same length as x) |
w_begin | Begin iterator of weight values (same length as x) |
compute_goodness | Compute meta stats about the fit. If this is not done, none of the members (except slope and intercept) are meaningful. |
- Exceptions
-