![]() |
aGrUM
0.16.0
|
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 More... | |
ExactBNdistance (const BNdistance< GUM_SCALAR > &kl) | |
copy constructor More... | |
virtual | ~ExactBNdistance () |
destructor More... | |
Complexity | difficulty () const |
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs __p and __q More... | |
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 Attributes | |
const IBayesNet< GUM_SCALAR > & | _p |
const IBayesNet< GUM_SCALAR > & | _q |
GUM_SCALAR | _klPQ |
GUM_SCALAR | _klQP |
GUM_SCALAR | _hellinger |
GUM_SCALAR | _bhattacharya |
GUM_SCALAR | _jsd |
Size | _errorPQ |
Size | _errorQP |
Protected Member Functions | |
void | _computeKL () final |
void | _process () |
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 70 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 37 of file exactBNdistance_tpl.h.
|
explicit |
copy constructor
Definition at line 44 of file exactBNdistance_tpl.h.
|
virtual |
destructor
Definition at line 51 of file exactBNdistance_tpl.h.
|
finalprotectedvirtual |
Reimplemented from gum::BNdistance< GUM_SCALAR >.
Definition at line 56 of file exactBNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_bhattacharya, gum::BNdistance< GUM_SCALAR >::_errorPQ, gum::BNdistance< GUM_SCALAR >::_errorQP, gum::BNdistance< GUM_SCALAR >::_hellinger, gum::BNdistance< GUM_SCALAR >::_jsd, gum::BNdistance< GUM_SCALAR >::_klPQ, gum::BNdistance< GUM_SCALAR >::_klQP, gum::BNdistance< GUM_SCALAR >::_p, gum::BNdistance< GUM_SCALAR >::_q, and gum::HashTable< Key, Val, Alloc >::insert().
|
protectedinherited |
Definition at line 178 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::__done, and gum::BNdistance< GUM_SCALAR >::_computeKL().
Referenced by gum::BNdistance< GUM_SCALAR >::bhattacharya(), gum::BNdistance< GUM_SCALAR >::errorPQ(), gum::BNdistance< GUM_SCALAR >::errorQP(), gum::BNdistance< GUM_SCALAR >::hellinger(), gum::BNdistance< GUM_SCALAR >::jsd(), gum::BNdistance< GUM_SCALAR >::klPQ(), and gum::BNdistance< GUM_SCALAR >::klQP().
|
inherited |
Definition at line 93 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_bhattacharya, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs __p and __q
Definition at line 70 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::__difficulty.
|
inherited |
Definition at line 105 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_errorPQ, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 111 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_errorQP, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 87 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_hellinger, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 99 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_jsd, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 75 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_klPQ, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 81 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_klQP, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 117 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_p.
|
inherited |
Definition at line 122 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_q.
|
protectedinherited |
Definition at line 142 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::bhattacharya().
|
protectedinherited |
Definition at line 145 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::errorPQ().
|
protectedinherited |
Definition at line 146 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::errorQP().
|
protectedinherited |
Definition at line 141 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::hellinger().
|
protectedinherited |
Definition at line 143 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::jsd().
|
protectedinherited |
Definition at line 139 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::klPQ().
|
protectedinherited |
Definition at line 140 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::klQP().
|
protectedinherited |
|
protectedinherited |
Definition at line 137 of file BNdistance.h.
Referenced by gum::BNdistance< GUM_SCALAR >::__checkCompatibility(), gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::q().