aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
contingencyTable.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
49
50
51#ifndef GUM_CONTINGENCY_TABLE_H
52#define GUM_CONTINGENCY_TABLE_H
53
55
57
58namespace gum {
59
69
70 template < typename GUM_ELEMENT_A, typename GUM_ELEMENT_B >
72 public:
73 // ##########################################################################
75 // ##########################################################################
77
78
80
82
83
85
87
88 // ============================================================================
90 // ============================================================================
91 void* operator new(size_t s);
92
93 void operator delete(void* p);
94
96
97
99
101
102
104
105 void add(GUM_ELEMENT_A valueA, GUM_ELEMENT_B valueB);
106
108
109 Idx joint(GUM_ELEMENT_A valueA, GUM_ELEMENT_B valueB) const;
110
112
113 Idx attrAMarginal(GUM_ELEMENT_A valueA) const;
114
116
117 Idx attrBMarginal(GUM_ELEMENT_B valueB) const;
118
120
121 // Idx aMarginal( GUM_ELEMENT_A iattr ) { return
122 // _attrMarginalTable_[iattr]; }
124
126
128
129 // Idx vMarginal( GUM_ELEMENT_B ivalue ) { return
130 // _valueMarginalTable_[ivalue]; }
132
134
136
137 Idx attrASize() const;
138
140
141 Idx attrBSize() const;
142
144
147
148 std::string toString() const;
149
150 private:
163 };
164
165} /* namespace gum */
166
168#endif // GUM_CONTINGENCY_TABLE_H
HashTable< GUM_ELEMENT_B, Idx > _attrBMarginalTable_
HashTableConstIteratorSafe< GUM_ELEMENT_B, Idx > attrBEndSafe() const
Increments the number of sample for case( iattr, ivalue ).
void add(GUM_ELEMENT_A valueA, GUM_ELEMENT_B valueB)
Increments the number of sample for case( iattr, ivalue ).
std::string toString() const
HashTable< GUM_ELEMENT_A, Idx > _attrAMarginalTable_
~ContingencyTable()
Default destructor.
ContingencyTable()
Default constructor.
Idx attrBMarginal(GUM_ELEMENT_B valueB) const
Returns the number of samples for case (iattr, ivalue).
HashTableConstIteratorSafe< GUM_ELEMENT_B, Idx > attrBBeginSafe() const
Returns the number of samples for column ivalue.
Idx attrAMarginal(GUM_ELEMENT_A valueA) const
Returns the number of samples for case (iattr, ivalue).
HashTableConstIteratorSafe< GUM_ELEMENT_A, Idx > attrAEndSafe() const
Increments the number of sample for case( iattr, ivalue ).
Idx attrASize() const
Returns the number of samples for line iattr.
HashTable< std::pair< GUM_ELEMENT_A, GUM_ELEMENT_B >, Idx > _jointTable_
The contingency table used to compute the GStat Left Idx is for the attribute Right Idx for the value...
Idx attrBSize() const
Returns the number of samples for column ivalue.
HashTableConstIteratorSafe< GUM_ELEMENT_A, Idx > attrABeginSafe() const
Returns the number of samples for line iattr.
Idx joint(GUM_ELEMENT_A valueA, GUM_ELEMENT_B valueB) const
Returns the number of samples for case (iattr, ivalue).
ContingencyTable< GUM_ELEMENT_A, GUM_ELEMENT_B > & operator+=(const ContingencyTable< GUM_ELEMENT_A, GUM_ELEMENT_B > &src)
The class for generic Hash Tables.
Definition hashTable.h:640
Template implementations for the ContingencyTable class.
Size Idx
Type for indexes.
Definition types.h:79
Useful macros for maths.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Headers of the Observation class.