Member Functions | |||
correlationCoeff() intercept() |
interceptStandardDev() operator<<() |
slope() slopeStandardDev() |
xPosition() yPosition() |
#include <rw/lsqfit.h> #include <rw/math/mathvec.h> RWMathVec<double> x, y; LeastSqFit lsf(x, y);
The class LeastSqFit constructs a linear least squares fit to a straight line from input data, with or without weighting factors. This class is of precision double. Once a LeastSqFit is constructed, various methods are provided to interrogate it.
LeastSqFit(const RWMathVec<double>& x, const RWMathVec<double>& y);
Constructs a linear least squares fit to the data in vectors x and y, without weights. Similar indices of the vectors x(i) and y(i) are assumed to represent (x,y) pairs. The vectors need not be the same length; trailing unmatched points are ignored.
LeastSqFit(const RWMathVec<double>& x, const RWMathVec<double>& y, const RWMathVec<double>& sigmay);
Constructs a linear least squares fit to the data in vectors x and y, using a set of known standard deviations for the y values. Similar indices of the vectors x(i) and y(i) are assumed to represent (x,y) pairs. These values are weighted according to the y standard deviations given as
1/sigmay(i)2. The vectors need not be the same length; trailing unmatched points are ignored.
double correlationCoeff() const;
Returns the sample linear correlation coefficient of the fit.
double intercept() const;
Returns the intercept of the line.
double interceptStandardDev() const;
Returns the standard deviation of the calculated intercept. If the standard deviations of the data is given, the standard deviation for the intercept is calculated appropriately. In the unweighted case, the standard deviation is estimated by factoring in the variance of the data from the calculated line.
double slope() const;
Returns the slope of the line.
double slopeStandardDev() const;
Returns the standard deviation of the calculated slope. If the standard deviations of the data are given, the standard deviation for the slope is calculated appropriately. In the unweighted case, the standard deviation is estimated by factoring in the variance of the data from the calculated line.
double xPosition(double y) const;
Using the linear fit, returns the value x corresponding to y.
double yPosition(double x) const;
Using the linear fit, returns the value y corresponding to x.
ostream& operator<<(ostream& s, const LeastSqFit& f);
Outputs a summary of the linear fit f on ostream s.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.