59 template < GUM_Numeric GUM_SCALAR >
67 double diff =
p_.log10DomainSize();
74 template < GUM_Numeric GUM_SCALAR >
81 template < GUM_Numeric GUM_SCALAR >
86 template < GUM_Numeric GUM_SCALAR >
91 template < GUM_Numeric GUM_SCALAR >
97 template < GUM_Numeric GUM_SCALAR >
103 template < GUM_Numeric GUM_SCALAR >
109 template < GUM_Numeric GUM_SCALAR >
115 template < GUM_Numeric GUM_SCALAR >
121 template < GUM_Numeric GUM_SCALAR >
127 template < GUM_Numeric GUM_SCALAR >
133 template < GUM_Numeric GUM_SCALAR >
138 template < GUM_Numeric GUM_SCALAR >
144 template < GUM_Numeric GUM_SCALAR >
147 if (
p_.size() !=
q_.size())
149 "BNdistance : the 2 BNs are not compatible (not the same size)")
151 for (
auto node:
p_.nodes()) {
153 if (!
q_.exists(vp.
name())) {
155 "BNdistance : the 2 BNs are not compatible (variable : " + vp.
name() +
")");
160 "BNdistance : the 2 BNs are not compatible "
161 "(not the same variable for the same name : "
165 if (std::fabs(
p_.log10DomainSize() -
q_.log10DomainSize()) > 1e-14) {
167 "BNdistance : the 2 BNs are not compatible (not the same domainSize) : p="
168 <<
p_.log10DomainSize() <<
" q=" <<
q_.log10DomainSize() <<
" => "
169 <<
p_.log10DomainSize() -
q_.log10DomainSize());
176 template < GUM_Numeric GUM_SCALAR >
185 template < GUM_Numeric GUM_SCALAR >
algorithm for KL divergence between BNs
#define GAP_COMPLEXITY_KL_DIFFICULT_CORRECT
#define GAP_COMPLEXITY_KL_HEAVY_DIFFICULT
Class representing the minimal interface for Bayesian network with no numerical data.
const IBayesNet< GUM_SCALAR > & q() const
BNdistance(const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q)
constructor must give 2 BNs
virtual void computeKL_()
const IBayesNet< GUM_SCALAR > & p() const
bool _checkCompatibility_() const
virtual ~BNdistance()
destructor
const IBayesNet< GUM_SCALAR > & q_
Complexity difficulty() const
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p...
const IBayesNet< GUM_SCALAR > & p_
Base class for discrete random variable.
std::string toString() const
string version of *this
Class representing the minimal interface for Bayesian network with no numerical data.
Exception : operation not allowed.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
gum is the global namespace for all aGrUM entities
Complexity
Complexity allows to characterize the awaited difficulty for an algorithm given a specific instance T...