aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
Chi2TestPolicy.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
50#ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_CHI2_TEST_POLICY_H
51#define GUM_MULTI_DIM_FUNCTION_GRAPH_CHI2_TEST_POLICY_H
52
53// ============================================================================
57
58// ============================================================================
59
60namespace gum {
61
71 template < typename GUM_ELEMENT >
72 class Chi2TestPolicy: public ITestPolicy< GUM_ELEMENT > {
73 public:
75
76 ~Chi2TestPolicy() override;
77
78 // ============================================================================
80 // ============================================================================
81 void* operator new(size_t s);
82
83 void operator delete(void* p);
84
85 // ############################################################################
87 // ############################################################################
89
90 // ============================================================================
92 // ============================================================================
93 void addObservation(Idx attr, GUM_ELEMENT value) override;
94
96
97
98 // ############################################################################
100 // ############################################################################
102
103 // ============================================================================
106 // ============================================================================
107 bool isTestRelevant() const override;
108
110
111
112 // ############################################################################
114 // ############################################################################
116
117 // ============================================================================
119 // ============================================================================
120 void computeScore() const override;
121
122 // ============================================================================
124 // ============================================================================
125 double score() const override;
126
127 // ============================================================================
129 // ============================================================================
130 double secondaryscore() const override;
131
133
135
136 void add(const Chi2TestPolicy< GUM_ELEMENT >& src);
137
138 std::string toString() const;
139
140 private:
143
144 mutable double _chi2Score_;
145 };
146
147} // End of namespace gum
148
150
151#endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_CHI2_TEST_POLICY_H */
Template implementations for the Chi2TestPolicy class.
Headers of the ITestPolicy.
Headers of the ChiSquare class.
void add(const Chi2TestPolicy< GUM_ELEMENT > &src)
void addObservation(Idx attr, GUM_ELEMENT value) override
Comptabilizes the new observation.
std::string toString() const
bool isTestRelevant() const override
Returns true if enough observation were made so that the test can be relevant.
void computeScore() const override
Recomputes the statistic from the beginning.
ContingencyTable< Idx, GUM_ELEMENT > _conTab_
The contingency table used to keeps records of all observation.
double secondaryscore() const override
Returns a second criterion to severe ties.
const ContingencyTable< Idx, GUM_ELEMENT > & ct() const
double score() const override
Returns the performance of current variable according to the test.
ITestPolicy()
Allocators and Deallocators redefinition.
Headers of the ContingencyTable class.
Size Idx
Type for indexes.
Definition types.h:79
gum is the global namespace for all aGrUM entities
Definition agrum.h:46