OpenMS
Loading...
Searching...
No Matches
LinearRegressionWithoutIntercept Class Reference

This class offers functions to perform least-squares fits to a straight line model, \( Y(c,x) = c_0 + c_1 x \). More...

#include <OpenMS/ML/REGRESSION/LinearRegressionWithoutIntercept.h>

Collaboration diagram for LinearRegressionWithoutIntercept:
[legend]

Public Member Functions

 LinearRegressionWithoutIntercept ()
 Constructor.
 
void addData (double x, double y)
 adds an observation (x,y) to the regression data set.
 
void addData (std::vector< double > &x, std::vector< double > &y)
 adds observations (x,y) to the regression data set.
 
double getSlope () const
 returns the slope of the estimated regression line.
 

Private Attributes

double sum_xx_
 total variation in x
 
double sum_xy_
 sum of products
 
int n_
 number of observations
 

Detailed Description

This class offers functions to perform least-squares fits to a straight line model, \( Y(c,x) = c_0 + c_1 x \).

Constructor & Destructor Documentation

◆ LinearRegressionWithoutIntercept()

Member Function Documentation

◆ addData() [1/2]

void addData ( double  x,
double  y 
)

adds an observation (x,y) to the regression data set.

Parameters
[in]xindependent variable value
[in]ydependent variable value

◆ addData() [2/2]

void addData ( std::vector< double > &  x,
std::vector< double > &  y 
)

adds observations (x,y) to the regression data set.

Parameters
[in]xvector of independent variable values
[in]yvector of dependent variable values

◆ getSlope()

double getSlope ( ) const

returns the slope of the estimated regression line.

Member Data Documentation

◆ n_

int n_
private

number of observations

◆ sum_xx_

double sum_xx_
private

total variation in x

◆ sum_xy_

double sum_xy_
private

sum of products