![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
ExactBNdistance computes exactly the KL divergence betweens 2 BNs. More...
#include <exactBNdistance.h>
Public Member Functions | |
| ExactBNdistance (const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q) | |
| constructor must give 2 BNs | |
| ExactBNdistance (const BNdistance< GUM_SCALAR > &kl) | |
| copy constructor | |
| virtual | ~ExactBNdistance () |
| destructor | |
| Complexity | difficulty () const |
| return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p and q | |
Accessors to results. The first call do the computations. The | |
others do not. | |
| double | klPQ () |
| Size | errorPQ () |
| double | klQP () |
| Size | errorQP () |
| double | hellinger () |
| double | bhattacharya () |
| double | jsd () |
| const IBayesNet< GUM_SCALAR > & | p () const |
| const IBayesNet< GUM_SCALAR > & | q () const |
Protected Member Functions | |
| void | computeKL_ () final |
| void | process_ () |
Protected Attributes | |
| const IBayesNet< GUM_SCALAR > & | p_ |
| const IBayesNet< GUM_SCALAR > & | q_ |
| GUM_SCALAR | klPQ_ |
| GUM_SCALAR | klQP_ |
| Size | errorPQ_ |
| Size | errorQP_ |
| GUM_SCALAR | hellinger_ |
| GUM_SCALAR | bhattacharya_ |
| GUM_SCALAR | jsd_ |
Private Member Functions | |
| bool | _checkCompatibility_ () const |
Private Attributes | |
| Complexity | _difficulty_ |
| bool | _done_ |
ExactBNdistance computes exactly the KL divergence betweens 2 BNs.
ExactBNdistance should be used only if difficulty() gives an estimation ( KL_CORRECT ) of the needed time. KL.process() computes KL(P||Q) using klPQ() and KL(Q||P) using klQP(). The computations are made once. The second is for free :) ExactBNdistance allows as well to compute in the same time the Hellinger distance ( \(*\sqrt{\sum_i (\sqrt{p_i}-\sqrt{q_i})^2}\)) (Kokolakis and Nanopoulos, 2001).
It may happen that P*ln(P/Q) is not computable (Q=0 and P!=0). In such a case, KL keeps working but trace this error (errorPQ() and errorQP())? *
Definition at line 89 of file exactBNdistance.h.
| gum::ExactBNdistance< GUM_SCALAR >::ExactBNdistance | ( | const IBayesNet< GUM_SCALAR > & | P, |
| const IBayesNet< GUM_SCALAR > & | Q ) |
constructor must give 2 BNs
| gum::OperationNotAllowed | if the 2 BNs have not the same domainSize or compatible node sets. |
Definition at line 58 of file exactBNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::BNdistance(), and ExactBNdistance().
Referenced by ExactBNdistance(), ExactBNdistance(), and ~ExactBNdistance().
|
explicit |
copy constructor
Definition at line 65 of file exactBNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::BNdistance(), and ExactBNdistance().
|
virtual |
destructor
Definition at line 71 of file exactBNdistance_tpl.h.
References ExactBNdistance().
|
privateinherited |
Definition at line 144 of file BNdistance_tpl.h.
References GUM_ERROR, gum::Variable::name(), p_, q_, and gum::DiscreteVariable::toString().
Referenced by BNdistance().
|
inherited |
Definition at line 109 of file BNdistance_tpl.h.
References bhattacharya_, and process_().
|
finalprotectedvirtual |
Reimplemented from gum::BNdistance< GUM_SCALAR >.
Definition at line 76 of file exactBNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::bhattacharya_, gum::BNdistance< GUM_SCALAR >::errorPQ_, gum::BNdistance< GUM_SCALAR >::errorQP_, GUM_LOG2_OR_0, gum::BNdistance< GUM_SCALAR >::hellinger_, gum::HashTable< Key, Val >::insert(), gum::BNdistance< GUM_SCALAR >::jsd_, gum::BNdistance< GUM_SCALAR >::klPQ_, gum::BNdistance< GUM_SCALAR >::klQP_, gum::BNdistance< GUM_SCALAR >::p_, and gum::BNdistance< GUM_SCALAR >::q_.
|
inherited |
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p and q
Definition at line 86 of file BNdistance_tpl.h.
References _difficulty_.
|
inherited |
Definition at line 121 of file BNdistance_tpl.h.
References errorPQ_, and process_().
|
inherited |
Definition at line 127 of file BNdistance_tpl.h.
References errorQP_, and process_().
|
inherited |
Definition at line 103 of file BNdistance_tpl.h.
References hellinger_, and process_().
|
inherited |
Definition at line 115 of file BNdistance_tpl.h.
References jsd_, and process_().
|
inherited |
Definition at line 91 of file BNdistance_tpl.h.
References klPQ_, and process_().
|
inherited |
Definition at line 97 of file BNdistance_tpl.h.
References klQP_, and process_().
|
inherited |
Definition at line 133 of file BNdistance_tpl.h.
References p_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance().
|
protectedinherited |
Definition at line 177 of file BNdistance_tpl.h.
References _done_, and computeKL_().
Referenced by bhattacharya(), errorPQ(), errorQP(), hellinger(), jsd(), klPQ(), and klQP().
|
inherited |
|
privateinherited |
Definition at line 171 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), and difficulty().
|
privateinherited |
Definition at line 172 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), and process_().
|
protectedinherited |
Definition at line 166 of file BNdistance.h.
Referenced by bhattacharya(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), and gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().
|
protectedinherited |
Definition at line 162 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and errorPQ().
|
protectedinherited |
Definition at line 163 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and errorQP().
|
protectedinherited |
Definition at line 165 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and hellinger().
|
protectedinherited |
Definition at line 167 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and jsd().
|
protectedinherited |
Definition at line 159 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and klPQ().
|
protectedinherited |
Definition at line 160 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and klQP().
|
protectedinherited |
Definition at line 156 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), _checkCompatibility_(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and p().
|
protectedinherited |
Definition at line 157 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), _checkCompatibility_(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and q().