IMP  2.1.0
The Integrative Modeling Platform
ParabolicFit.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/ParabolicFit.h
3  * \brief fit the data with parabola
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPALGEBRA_PARABOLIC_FIT_H
10 #define IMPALGEBRA_PARABOLIC_FIT_H
11 
12 #include "Vector2D.h"
13 #include "GeometricPrimitiveD.h"
14 #include <vector>
15 
16 IMPALGEBRA_BEGIN_NAMESPACE
17 
18 //! Calculate parabola that fits best the input data points
19 class IMPALGEBRAEXPORT ParabolicFit2D : public GeometricPrimitiveD<2> {
20  public:
21 
22  //! Constructor
23  /**
24  \param[in] data vector of pairs (VectorD<2>) with x and their
25  corresponding y values
26  */
27  ParabolicFit2D(const Vector2Ds& data);
28 
29  //! fit error
30  double get_fit_error() const { return error_; }
31 
32  //! get a value (a*x^2)
33  double get_a() const { return a_; }
34 
35  //! get b value (b*x)
36  double get_b() const { return b_; }
37 
38  //! get c value (constant)
39  double get_c() const { return c_; }
40 
42  out << "y = " << a_ << "x^2 + " << b_ << "x + " << c_ << std::endl;
43  out << "Error = " << error_ << std::endl;
44  });
45 
46  private:
47  void find_regression(const Vector2Ds& data);
48  void evaluate_error(const Vector2Ds& data);
49 
50  private:
51  double a_, b_, c_;
52  double error_;
53 };
54 
56 #ifndef IMP_DOXYGEN
57 typedef ParabolicFit2D ParabolicFit;
58 #endif
59 
60 IMPALGEBRA_END_NAMESPACE
61 
62 #endif /* IMPALGEBRA_PARABOLIC_FIT_H */
Basic types used by IMP.
double get_b() const
get b value (b*x)
Definition: ParabolicFit.h:36
Simple 2D vector class.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
base::Vector< VectorD< 2 > > Vector2Ds
Definition: VectorD.h:585
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Calculate parabola that fits best the input data points.
Definition: ParabolicFit.h:19
double get_c() const
get c value (constant)
Definition: ParabolicFit.h:39
double get_fit_error() const
fit error
Definition: ParabolicFit.h:30
double get_a() const
get a value (a*x^2)
Definition: ParabolicFit.h:33