aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
informationTheory.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 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-2025 *
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#ifndef GUM_INFORMATION_THEORY
51#define GUM_INFORMATION_THEORY
52#include <concepts>
53#include <functional>
54
55#include <agrum/agrum.h>
56
58
59namespace gum {
60 template < typename T >
61 concept JointTargettable = requires(T t, const NodeSet& target) {
62 { t.addJointTarget(target) } -> std::same_as< void >;
63 };
64
80 template < template < typename > class INFERENCE_ENGINE, typename GUM_SCALAR >
81 //@todo when CLANG-compliant for virtual class: requires JointTargettable< INFERENCE_ENGINE<
82 // GUM_SCALAR > >
84 public:
85 InformationTheory(INFERENCE_ENGINE< GUM_SCALAR >& engine,
86 NodeSet X, // X,Y,Z passed by Value & move
87 NodeSet Y,
88 NodeSet Z);
89 InformationTheory(INFERENCE_ENGINE< GUM_SCALAR >& engine, const NodeSet& X, const NodeSet& Y);
90 InformationTheory(INFERENCE_ENGINE< GUM_SCALAR >& engine,
91 const std::vector< std::string >& Xnames,
92 const std::vector< std::string >& Ynames);
93 InformationTheory(INFERENCE_ENGINE< GUM_SCALAR >& engine,
94 const std::vector< std::string >& Xnames,
95 const std::vector< std::string >& Ynames,
96 const std::vector< std::string >& Znames);
98
99 GUM_SCALAR entropyXY();
100 GUM_SCALAR entropyX();
101 GUM_SCALAR entropyY();
102
103 GUM_SCALAR entropyXgivenY();
104 GUM_SCALAR entropyYgivenX();
105 GUM_SCALAR mutualInformationXY();
106 GUM_SCALAR variationOfInformationXY();
107
108
109 GUM_SCALAR entropyXgivenZ();
110 GUM_SCALAR entropyYgivenZ();
111 GUM_SCALAR entropyXYgivenZ();
112 GUM_SCALAR entropyXgivenYZ();
113 GUM_SCALAR mutualInformationXYgivenZ();
114
115 protected:
116 INFERENCE_ENGINE< GUM_SCALAR >& engine_;
117
118 const NodeSet X_;
119 const NodeSet Y_;
120 const NodeSet Z_;
121
125
126 Tensor< GUM_SCALAR > pXYZ_;
127 Tensor< GUM_SCALAR > pXY_;
128 Tensor< GUM_SCALAR > pXZ_;
129 Tensor< GUM_SCALAR > pYZ_;
130 Tensor< GUM_SCALAR > pX_;
131 Tensor< GUM_SCALAR > pY_;
132 Tensor< GUM_SCALAR > pZ_;
133
134 void makeInference_();
135 };
136} // namespace gum
137
139#endif // GUM_INFORMATION_THEORY
Tensor< GUM_SCALAR > pY_
Tensor< GUM_SCALAR > pXYZ_
Tensor< GUM_SCALAR > pX_
InformationTheory(INFERENCE_ENGINE< GUM_SCALAR > &engine, NodeSet X, NodeSet Y, NodeSet Z)
Tensor< GUM_SCALAR > pXZ_
Tensor< GUM_SCALAR > pYZ_
Tensor< GUM_SCALAR > pZ_
INFERENCE_ENGINE< GUM_SCALAR > & engine_
Tensor< GUM_SCALAR > pXY_
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Implementation of the Class encapsulating computations of notions from Information Theory.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
Header of the Tensor class.