Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FittingStatistics.h
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef FITTING_STATISTICS_H
8 #define FITTING_STATISTICS_H
9 
12 #include <QVector>
13 
14 const int MAX_POLYNOMIAL_ORDER = 9; // Check execution time if this is increased from, say, 6 or 7
15 
16 class Matrix;
17 
20 {
21  // For unit testing
22  friend class TestFitting;
23 
24 public:
27  virtual ~FittingStatistics ();
28 
39  void calculateCurveFitAndStatistics (unsigned int order,
40  const FittingPointsConvenient &pointsConvenient,
41  FittingCurveCoefficients &coefficients,
42  double &mse,
43  double &rms,
44  double &rSquared,
45  int significantDigits);
46 
47 private:
48 
49  void calculateCurveFit (int orderReduced,
50  const FittingPointsConvenient &pointsConvenient,
51  FittingCurveCoefficients &coefficients,
52  int significantDigits);
53  bool calculateCurveFitReducedFurther (int orderReducedFurther,
54  const FittingPointsConvenient &pointsConvenient,
55  int significantDigits,
56  QVector<double> &a) const;
57  void calculateStatistics (const FittingPointsConvenient &pointsConvenient,
58  const FittingCurveCoefficients &coefficients,
59  double &mse,
60  double &rms,
61  double &rSquared);
62  void loadXAndYArrays (int orderReduced,
63  const FittingPointsConvenient &pointsConvenient,
64  Matrix &X,
65  QVector<double> &Y) const;
66  double yFromXAndCoefficients (const FittingCurveCoefficients &coefficients,
67  double x) const;
68 };
69 
70 #endif // FITTING_STATISTICS_H
Unit test of Fitting classes.
Definition: TestFitting.h:7
void calculateCurveFitAndStatistics(unsigned int order, const FittingPointsConvenient &pointsConvenient, FittingCurveCoefficients &coefficients, double &mse, double &rms, double &rSquared, int significantDigits)
Compute the curve fit and the statistics for that curve fit.
const int MAX_POLYNOMIAL_ORDER
QList< QPointF > FittingPointsConvenient
Array of (x,y) points in graph coordinates.
FittingStatistics()
Single constructor.
Matrix class that supports arbitrary NxN size.
Definition: Matrix.h:20
QVector< double > FittingCurveCoefficients
Coefficients x0, x1, ... in y = a0 + a1 * x + a2 * x^2 + ...
This class does the math to compute statistics for FittingWindow.