OpenMS
Loading...
Searching...
No Matches
ModifiedSincSmoother::LinearRegression Struct Reference

Helper class for weighted linear regression. More...

Collaboration diagram for ModifiedSincSmoother::LinearRegression:
[legend]

Public Member Functions

void clear ()
 Reset accumulator for new regression.
 
void addPointW (double x, double y, double weight)
 Add a weighted data point to the regression.
 
void calculate ()
 Compute least-squares line parameters.
 
double getOffset ()
 Get regression intercept (y-value at x=0).
 
double getSlope ()
 Get regression slope (dy/dx).
 

Public Attributes

double sum_weights = 0
 Sum of weights.
 
double sum_x = 0
 Sum of weighted x values.
 
double sum_y = 0
 Sum of weighted y values

 
double sum_xy = 0
 Sum of weighted x*y products.
 
double sum_x2 = 0
 Sum of weighted x² values.
 
double offset = NAN
 Regression intercept (cached)
 
double slope = NAN
 Regression slope (cached)
 
bool calculated = false
 Whether regression has been computed.
 

Detailed Description

Helper class for weighted linear regression.

Accumulates weighted (x,y) points and computes least-squares line fit on demand. Used for boundary extrapolation.

Member Function Documentation

◆ addPointW()

void addPointW ( double  x,
double  y,
double  weight 
)

Add a weighted data point to the regression.

Parameters
xindependent variable value
ydependent variable value
weightpoint weight (≥ 0)

◆ calculate()

void calculate ( )

Compute least-squares line parameters.

Solves normal equations for weighted linear regression. Sets calculated = true and caches offset/slope.

Note
Handles singular cases by setting slope = 0
Automatically called by getOffset()/getSlope() if needed

◆ clear()

void clear ( )

Reset accumulator for new regression.

◆ getOffset()

double getOffset ( )

Get regression intercept (y-value at x=0).

Returns
regression offset parameter
Note
Triggers calculate() if not already computed

◆ getSlope()

double getSlope ( )

Get regression slope (dy/dx).

Returns
regression slope parameter
Note
Triggers calculate() if not already computed

Member Data Documentation

◆ calculated

bool calculated = false

Whether regression has been computed.

◆ offset

double offset = NAN

Regression intercept (cached)

◆ slope

double slope = NAN

Regression slope (cached)

◆ sum_weights

double sum_weights = 0

Sum of weights.

◆ sum_x

double sum_x = 0

Sum of weighted x values.

◆ sum_x2

double sum_x2 = 0

Sum of weighted x² values.

◆ sum_xy

double sum_xy = 0

Sum of weighted x*y products.

◆ sum_y

double sum_y = 0

Sum of weighted y values