MINT2
HyperStatisticsFinder.cpp
Go to the documentation of this file.
2 #include <math.h>
3 
4 
5 HyperStatisticsFinder::HyperStatisticsFinder(int dim, bool mean, bool width, bool widthError, bool keepOrderedEvents) :
6  _dim(dim)
7 {
8 
9  for (int i = 0; i < _dim; i++){
10  std::vector<StatisticsFinder> statsFinders;
11  for (int j = 0; j < _dim; j++){
12  statsFinders.push_back( StatisticsFinder(mean, width, widthError, keepOrderedEvents) );
13  }
14  _statisticsFinders.push_back(statsFinders);
15  }
16 
17 }
18 
19 HyperStatisticsFinder::HyperStatisticsFinder(const HyperPoint& x, bool mean, bool width, bool widthError, bool keepOrderedEvents) :
20  _dim(x.getDimension())
21 {
22 
23  for (int i = 0; i < _dim; i++){
24  std::vector<StatisticsFinder> statsFinders;
25  for (int j = 0; j < _dim; j++){
26  statsFinders.push_back( StatisticsFinder(mean, width, widthError, keepOrderedEvents) );
27  }
28  _statisticsFinders.push_back(statsFinders);
29  }
30 
31  add(x);
32 
33 }
34 
36 
37  if (x.getDimension() != _dim) ERROR_LOG << "The HyperPoint you are adding is not of the correct dimension";
38 
39  for (int i = 0; i < _dim; i++){
40  for (int j = 0; j < _dim; j++){
41  double val = 0.0;
42  if (i == j) val = x.at(i);
43  if (i != j) val = x.at(i)*x.at(j);
44  _statisticsFinders.at(i).at(j).add( val, x.getWeight() );
45  }
46  }
47 
48 }
49 
50 double HyperStatisticsFinder::correlation(int i, int j) const{
51 
52  return covarience(i,j)/sqrt(covarience(i,i)*covarience(j,j));
53 
54 }
55 
56 
57 
58 
59 
60 
61 double HyperStatisticsFinder::covarience(int i, int j) const{
62 
63  if (i == j) {
64  return _statisticsFinders.at(i).at(i).varience();
65  }
66 
67  const StatisticsFinder& statsI = _statisticsFinders.at(i).at(i);
68  const StatisticsFinder& statsJ = _statisticsFinders.at(j).at(j);
69  const StatisticsFinder& statsIJ = _statisticsFinders.at(i).at(j);
70 
71  double expI = statsI .mean();
72  double expJ = statsJ .mean();
73  double expIJ = statsIJ.mean();
74 
75  return expIJ - expI*expJ;
76 
77 }
78 
79 
80 double HyperStatisticsFinder::mean(int i) const{
81  return _statisticsFinders.at(i).at(i).mean();
82 }
83 
85  return _statisticsFinders.at(i).at(i).meanError();
86 }
87 
88 double HyperStatisticsFinder::width(int i) const{
89  return _statisticsFinders.at(i).at(i).width();
90 }
91 
92 double HyperStatisticsFinder::getMin(int i) const{
93  return _statisticsFinders.at(i).at(i).getMin();
94 }
95 
96 double HyperStatisticsFinder::getMax(int i) const{
97  return _statisticsFinders.at(i).at(i).getMax();
98 }
99 
100 
101 
102 
104  HyperPoint point(_dim);
105  for (int i = 0; i < _dim; i++) point.at(i) = _statisticsFinders.at(i).at(i).mean();
106  return point;
107 }
108 
110  HyperPoint point(_dim);
111  for (int i = 0; i < _dim; i++) point.at(i) = _statisticsFinders.at(i).at(i).meanError();
112  return point;
113 }
114 
116  HyperPoint point(_dim);
117  for (int i = 0; i < _dim; i++) point.at(i) = _statisticsFinders.at(i).at(i).width();
118  return point;
119 }
120 
122  HyperPoint point(_dim);
123  for (int i = 0; i < _dim; i++) point.at(i) = _statisticsFinders.at(i).at(i).getMin();
124  return point;
125 }
126 
128  HyperPoint point(_dim);
129  for (int i = 0; i < _dim; i++) point.at(i) = _statisticsFinders.at(i).at(i).getMax();
130  return point;
131 }
132 
133 
135 
136 }
137 
138 
std::vector< std::vector< StatisticsFinder > > _statisticsFinders
double correlation(int i, int j) const
#define ERROR_LOG
HyperStatisticsFinder(int dimension, bool mean=1, bool width=1, bool widthError=1, bool keepOrderedEvents=0)
const double & at(int i) const
Definition: HyperPoint.cpp:433
void add(const HyperPoint &x)
double getWeight(int i=0) const
Definition: Weights.cpp:40
double covarience(int i, int j) const
int getDimension() const
Definition: HyperPoint.h:99
double mean() const