34 template <
typename GUM_SCALAR >
38 _q(Q), _klPQ(0.0), _klQP(0.0), _errorPQ(0), _errorQP(0),
43 double diff =
_p.log10DomainSize();
53 template <
typename GUM_SCALAR >
61 template <
typename GUM_SCALAR >
66 template <
typename GUM_SCALAR >
71 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
83 template <
typename GUM_SCALAR >
89 template <
typename GUM_SCALAR >
95 template <
typename GUM_SCALAR >
101 template <
typename GUM_SCALAR >
107 template <
typename GUM_SCALAR >
113 template <
typename GUM_SCALAR >
118 template <
typename GUM_SCALAR >
124 template <
typename GUM_SCALAR >
126 for (
auto node :
_p.nodes()) {
134 "BNdistance : the 2 BNs are not compatible " 135 "(not the same domainSize for " 145 "BNdistance : the 2 BNs are not compatible F(not the same " 152 "BNdistance : the 2 BNs are not compatible (not the same vars : " 158 if (
_p.size() !=
_q.size())
160 "BNdistance : the 2 BNs are not compatible (not the same size)");
162 if (std::fabs(
_p.log10DomainSize() -
_q.log10DomainSize()) > 1e-14) {
165 "BNdistance : the 2 BNs are not compatible (not the same domainSize) : p=" 166 <<
_p.log10DomainSize() <<
" q=" <<
_q.log10DomainSize() <<
" => " 167 <<
_p.log10DomainSize() -
_q.log10DomainSize());
174 template <
typename GUM_SCALAR >
183 template <
typename GUM_SCALAR >
Complexity difficulty() const
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs _...
bool __checkCompatibility() const
const IBayesNet< GUM_SCALAR > & _p
BNdistance(const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q)
constructor must give 2 BNs
Class representing Bayesian networks.
const IBayesNet< GUM_SCALAR > & p() const
Base class for discrete random variable.
algorithm for KL divergence between BNs
Class representing the minimal interface for Bayesian Network.
gum is the global namespace for all aGrUM entities
virtual void _computeKL()
Complexity
Complexity allows to characterize the awaited difficulty for an algorithm given a specific instance T...
virtual Size domainSize() const =0
const IBayesNet< GUM_SCALAR > & _q
#define GAP_COMPLEXITY_KL_DIFFICULT_CORRECT
const IBayesNet< GUM_SCALAR > & q() const
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual ~BNdistance()
destructor
Size Idx
Type for indexes.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
#define GAP_COMPLEXITY_KL_HEAVY_DIFFICULT
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)