Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
JRegressor.hh
Go to the documentation of this file.
1#ifndef __JFIT__JREGRESSOR__
2#define __JFIT__JREGRESSOR__
3
4#include "Jeep/JMessage.hh"
5
6
7/**
8 * \file
9 * General purpose data regression method.
10 * \author mdejong
11 */
12namespace JFIT {}
13namespace JPP { using namespace JFIT; }
14
15namespace JFIT {
16
17 using JEEP::JMessage;
18
19
20 /**
21 * Abstract minimiser.
22 * This "minimiser" can be used to determine the chi2 of the data for a given model value.
23 */
24 template<class JModel_t>
26 public JMessage< JAbstractMinimiser<JModel_t> >
27 {
28 public:
29
30 typedef double result_type;
31
32 /**
33 * Default constructor.
34 */
37
38
39 /**
40 * Get chi2.
41 *
42 * \param fit fit function
43 * \param __begin begin of data
44 * \param __end end of data
45 * \return chi2
46 */
47 template<class JFunction_t, class T>
48 result_type operator()(const JFunction_t& fit, T __begin, T __end)
49 {
50 double chi2 = 0.0;
51
52 for (T i = __begin; i != __end; ++i) {
53 chi2 += fit(value, *i);
54 }
55
56 return chi2;
57 }
58
59 JModel_t value; //!< model value
60 };
61
62
63 /**
64 * Template definition of a data regressor of given model.
65 *
66 * The first template argument refers to the model that should be fitted to the data and
67 * the second to the type of minimiser.
68 */
69 template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
70 struct JRegressor;
71
72
73 /**
74 * Abstract class for global fit method.
75 */
76 template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
78 public JMinimiser_t<JModel_t>
79 {
80 typedef JMinimiser_t<JModel_t> minimiser_type;
82 typedef typename minimiser_type::result_type result_type;
83
84
85 /**
86 * Global fit.
87 *
88 * \param value start value
89 * \param __begin begin of data set
90 * \param __end end of data set
91 * \return chi2
92 */
93 template<class T>
94 result_type operator()(const JModel_t& value, T __begin, T __end)
95 {
96 static_cast<minimiser_type&>(*this).value = value;
97
98 return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
99 }
100 };
101
102
103 /**
104 * Template data structure for storage of internal data.
105 */
106 template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
108}
109
110#endif
General purpose messaging.
Abstract minimiser.
Definition JRegressor.hh:27
JModel_t value
model value
Definition JRegressor.hh:59
result_type operator()(const JFunction_t &fit, T __begin, T __end)
Get chi2.
Definition JRegressor.hh:48
JAbstractMinimiser()
Default constructor.
Definition JRegressor.hh:35
Template definition of a multi-dimensional oscillation probability interpolation table.
Auxiliary classes and methods for linear and iterative data regression.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for handling debug parameter within a class.
Definition JMessage.hh:44
Abstract class for global fit method.
Definition JRegressor.hh:79
JMinimiser_t< JModel_t > minimiser_type
Definition JRegressor.hh:80
JRegressor< JModel_t, JMinimiser_t > regressor_type
Definition JRegressor.hh:81
result_type operator()(const JModel_t &value, T __begin, T __end)
Global fit.
Definition JRegressor.hh:94
minimiser_type::result_type result_type
Definition JRegressor.hh:82
Template data structure for storage of internal data.
Template definition of a data regressor of given model.
Definition JRegressor.hh:70