PCL
|
Robust straight line fitting by minimization of mean absolute deviation. More...
#include <LinearFit.h>
Public Member Functions | |
LinearFit ()=default | |
template<class C > | |
LinearFit (const C &x, const C &y, StatusMonitor *status=nullptr) | |
LinearFit (const LinearFit &)=default | |
template<typename T > | |
LinearFit (const T *x, const T *y, size_type n, StatusMonitor *status=nullptr) | |
template<typename T > | |
LinearFit (T x1, T y1, T x2, T y2) | |
bool | IsIdentity () const |
bool | IsValid () const |
bool | IsXAxis () const |
double | operator() (double x) const |
Public Attributes | |
double | a = 0 |
double | adev = 0 |
double | b = 0 |
Given a set of N data points {xi,yi} for i = {0,...,N-1}, LinearFit finds the parameters a,b of the linear function:
y = L(x) := a + b*x
that minimizes mean absolute deviation for all the data points. The a parameter of L() is the ordinate of its intersection with the Y axis. The b parameter is the slope of the fitted straight line.
Definition at line 83 of file LinearFit.h.
|
default |
Constructs a default LinearFit object. The resulting object corresponds to a horizontal line crossing at the origin, i.e. the X axis.
|
default |
Copy constructor.
|
inline |
Constructs a LinearFit object representing the straight line that passes through two points {x1,y1} and {x2,y2}.
Definition at line 170 of file LinearFit.h.
|
inline |
Constructs a LinearFit object to fit a straight line for the specified set of data points.
x | Array of abscissae values. |
y | Array of ordinate values. |
n | Number of data points. Must be >= 2. |
status | If nonzero, pointer to a StatusMonitor object that will be updated during the fitting process. The linear fit process is unbounded, i.e., the total number of monitoring steps cannot be known in advance. The default value is zero (no monitoring). |
When n >= 3, this constructor fits the straight line that minimizes mean absolute deviation for all the source data points. When n == 2, this function finds the straight line that passes through the two data points. When n < 2, this constructor throws an Error exception.
Definition at line 199 of file LinearFit.h.
|
inline |
Constructs a LinearFit object to fit a straight line for the specified data containers.
x | Container of abscissae values. |
y | Container of ordinate values. |
status | If nonzero, pointer to a StatusMonitor object that will be updated during the fitting process. The linear fit process is unbounded, i.e., the total number of monitoring steps cannot be known in advance. The default value is zero (no monitoring). |
The number n of data points is the minimum container length, i.e.:
n = Min( x.Length(), y.Length() )
When n >= 3, this constructor fits the straight line that minimizes mean absolute deviation for all the source data points. When n == 2, this function finds the straight line that passes through the two data points. When n < 2, this constructor throws an Error exception.
Definition at line 238 of file LinearFit.h.
|
inline |
Returns true iff this is an identity function. This is true when the line parameters are a = 0 and b = 1 to machine epsilon.
Definition at line 137 of file LinearFit.h.
|
inline |
Returns true iff the fitted straight line model is valid. The model function is valid if the slope parameter is finite, i.e., if the fitted line is not vertical.
Definition at line 119 of file LinearFit.h.
References pcl::IsFinite().
|
inline |
Returns true iff the fitted straight line is coincident with the X axis. This is true when both line parameters a = b = 0 to machine epsilon.
Definition at line 128 of file LinearFit.h.
|
inline |
Evaluates the fitted line function for the specified abscissa x.
Definition at line 145 of file LinearFit.h.
double pcl::LinearFit::a = 0 |
The a parameter of the fitted straight line:
y = a + b*x
is the ordinate of its intersection with the Y axis. It represents a constant additive pedestal present in the whole dataset.
Definition at line 95 of file LinearFit.h.
double pcl::LinearFit::adev = 0 |
Mean absolute deviation of the linear fit. This is the mean absolute deviation computed for all data points with respect to the fitted straight line function.
Definition at line 112 of file LinearFit.h.
double pcl::LinearFit::b = 0 |
The b parameter is the slope of the fitted straight line:
y = a + b*x
If the fitted line passes through two points {x1,y1} and {x2,y2}, then its slope is equal to (y2 - y1)/(x2 - x1).
Definition at line 105 of file LinearFit.h.