leastsqs.hxx File Reference

Implements a simple linear least squares best fit routine. More...

Go to the source code of this file.

Functions

void least_squares (double *x, double *y, int n, double *m, double *b)
 Classical least squares fit:.
void least_squares_update (double x, double y, double *m, double *b)
 Incrimentally update existing values with a new data point.
double least_squares_error (double *x, double *y, int n, double m, double b)
double least_squares_max_error (double *x, double *y, int n, double m, double b)

Detailed Description

Implements a simple linear least squares best fit routine.

Definition in file leastsqs.hxx.


Function Documentation

void least_squares ( double *  x,
double *  y,
int  n,
double *  m,
double *  b 
)

Classical least squares fit:.

\[ y = b_0 + b_1 * x \]

\[ b_1 = \frac{n * \sum_0^{i-1} (x_i*y_i) - \sum_0^{i-1} x_i* \sum_0^{i-1} y_i} {n*\sum_0^{i-1} x_i^2 - (\sum_0^{i-1} x_i)^2} \]

\[ b_0 = \frac{\sum_0^{i-1} y_i}{n} - b_1 * \frac{\sum_0^{i-1} x_i}{n} \]

Definition at line 46 of file leastsqs.cxx.

double least_squares_error ( double *  x,
double *  y,
int  n,
double  m,
double  b 
)
Returns:
the least squares error:.

\[ \frac{(y_i - \hat{y}_i)^2}{n} \]

Definition at line 97 of file leastsqs.cxx.

double least_squares_max_error ( double *  x,
double *  y,
int  n,
double  m,
double  b 
)
Returns:
the maximum least squares error.

\[ (y_i - \hat{y}_i)^2 \]

Definition at line 118 of file leastsqs.cxx.


Generated on 23 Feb 2010 for SimGear by  doxygen 1.6.1