aGrUM  0.14.2
leastSquareTestPolicy.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H
28 #define GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H
29 
30 // ============================================================================
33 // ============================================================================
35 // ============================================================================
36 
37 namespace gum {
38 
48  template < typename GUM_SCALAR >
49  class LeastSquareTestPolicy : public ITestPolicy< GUM_SCALAR > {
50  public:
51  // ############################################################################
53  // ############################################################################
55 
56  // ============================================================================
58  // ============================================================================
60  ITestPolicy< GUM_SCALAR >(), __sumO(0.0), __score(0) {
61  GUM_CONSTRUCTOR(LeastSquareTestPolicy);
62  }
63 
64  // ============================================================================
66  // ============================================================================
67  void* operator new(size_t s) {
69  }
70  void operator delete(void* p) {
72  sizeof(LeastSquareTestPolicy));
73  }
74 
75  // ============================================================================
77  // ============================================================================
78  virtual ~LeastSquareTestPolicy();
79 
80  // ############################################################################
82  // ############################################################################
84 
85  // ============================================================================
87  // ============================================================================
88  void addObservation(Idx attr, GUM_SCALAR value);
89 
91 
92 
93  // ############################################################################
95  // ############################################################################
97 
98  // ============================================================================
101  // ============================================================================
102  bool isTestRelevant() const { return (this->nbObservation() > 20); }
103 
105 
106 
107  // ############################################################################
109  // ############################################################################
111 
112  // ============================================================================
114  // ============================================================================
115  void computeScore();
116 
117  // ============================================================================
119  // ============================================================================
120  double score();
121 
122  // ============================================================================
124  // ============================================================================
125  double secondaryscore() const;
126 
128 
129 
130  // ############################################################################
132  // ############################################################################
134 
135  // ============================================================================
138  // ============================================================================
139  void add(const LeastSquareTestPolicy< GUM_SCALAR >& src);
140 
141 
142  // ============================================================================
144  // ============================================================================
145  double sumValue() const { return __sumO; }
146 
147  // ============================================================================
149  // ============================================================================
150  const HashTable< Idx, Idx >& nbObsTable() const { return __nbObsTable; }
151 
152  // ============================================================================
154  // ============================================================================
156 
157  // ============================================================================
159  // ============================================================================
161  return __obsTable;
162  }
163 
164  private:
166  double __sumO;
167 
170 
173 
176 
178  double __score;
179  };
180 
181 } // End of namespace gum
182 
184 
185 #endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H */
const HashTable< Idx, LinkedList< double > *> & obsTable() const
Returns global sum (needed for the merging)
double score()
Returns the performance of current variable according to the test.
const HashTable< Idx, Idx > & nbObsTable() const
Returns nbobs per modality table (needed for the merging)
HashTable< Idx, LinkedList< double > *> __obsTable
Not sure if needed.
virtual ~LeastSquareTestPolicy()
Destructor.
double secondaryscore() const
Returns a second criterion to severe ties.
const HashTable< Idx, double > & sumAttrTable() const
Returns sum per modality table (needed for the merging)
void add(const LeastSquareTestPolicy< GUM_SCALAR > &src)
Performs the merging of current LeastSquareTestPolicy instance with given instance.
double sumValue() const
Returns global sum (needed for the merging)
Headers of the ITestPolicy.
bool isTestRelevant() const
Returns true if enough observation were made so that the test can be relevant.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
HashTable< Idx, Idx > __nbObsTable
Nb Observation for each modality assumed by variable.
<agrum/multidim/core/testPolicy/leastSquareTestPolicy.h>
void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
<agrum/multidim/core/testPolicies/ITestPolicy.h>
Definition: ITestPolicy.h:47
Headers of the ContingencyTable class.
void computeScore()
Returns the performance of current variable according to the test.
double __score
Keeping computed score.
Template implementations for the LeastSquareTestPolicy class.
HashTable< Idx, double > __sumAttrTable
Sum for each modality assumed by variable.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Size Idx
Type for indexes.
Definition: types.h:50
void * allocate(const size_t &objectSize)
Allocates a block.
Idx nbObservation() const
Comptabilizes the new observation.
Definition: ITestPolicy.h:95
static SmallObjectAllocator & instance()