aGrUM  0.16.0
BNdistance.h
Go to the documentation of this file.
1 
30 #ifndef GUM_KL_H
31 #define GUM_KL_H
32 
33 #include <agrum/BN/IBayesNet.h>
34 #include <agrum/core/sequence.h>
35 
36 namespace gum {
37 
46  enum class Complexity : char { Heavy, Difficult, Correct };
47 
67  template < typename GUM_SCALAR >
68  class BNdistance {
69 // difficulty is chosen w.r.t the log10DomainSize of the BN
70 #define GAP_COMPLEXITY_KL_HEAVY_DIFFICULT double(12.0)
71 #define GAP_COMPLEXITY_KL_DIFFICULT_CORRECT double(7.0)
72  public:
78  BNdistance(const IBayesNet< GUM_SCALAR >& P, const IBayesNet< GUM_SCALAR >& Q);
79 
82  BNdistance(const BNdistance< GUM_SCALAR >& kl);
83 
85  virtual ~BNdistance();
86 
92  Complexity difficulty() const;
93 
98 
100  double klPQ();
101 
103  Size errorPQ();
104 
106  double klQP();
107 
109  Size errorQP();
110 
113  double hellinger();
114 
117  double bhattacharya();
118 
121  double jsd();
122 
124  const IBayesNet< GUM_SCALAR >& p() const;
125 
127  const IBayesNet< GUM_SCALAR >& q() const;
129 
130  protected:
131  // should be pure virtual but using BNdistance directly is a way to delay the
132  // choice between different computation scheme (@see ExactBNdistance)
133  virtual void _computeKL();
134  void _process();
135 
138 
139  GUM_SCALAR _klPQ;
140  GUM_SCALAR _klQP;
141  GUM_SCALAR _hellinger;
142  GUM_SCALAR _bhattacharya;
143  GUM_SCALAR _jsd;
144 
147 
148  private:
149  bool __checkCompatibility() const;
151  bool __done;
152  };
153 
154 
155 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
156  extern template class BNdistance< double >;
157 #endif
158 
159 } // namespace gum
160 
162 
163 #endif // GUM_KL_H
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
GUM_SCALAR _klPQ
Definition: BNdistance.h:139
GUM_SCALAR _bhattacharya
Definition: BNdistance.h:142
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const IBayesNet< GUM_SCALAR > & _p
Definition: BNdistance.h:136
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
GUM_SCALAR _jsd
Definition: BNdistance.h:143
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Complexity
Complexity allows to characterize the awaited difficulty for an algorithm given a specific instance T...
Definition: BNdistance.h:46
const IBayesNet< GUM_SCALAR > & _q
Definition: BNdistance.h:137
GUM_SCALAR _hellinger
Definition: BNdistance.h:141
GUM_SCALAR _klQP
Definition: BNdistance.h:140
Complexity __difficulty
Definition: BNdistance.h:150
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48