51#ifndef DOXYGEN_SHOULD_SKIP_THIS
66 _param_complexity_ = from._param_complexity_;
75 _param_complexity_ = std::move(from._param_complexity_);
83 _param_complexity_.clearCache();
89 _param_complexity_.clearCache();
95 _param_complexity_.useCache(on_off);
105 const bool informative_external_prior = this->
prior_->isInformative();
110 std::size_t r_x, r_y;
111 if (!node2cols.empty()) {
112 r_x = db.domainSize(node2cols.second(idset[0]));
113 r_y = db.domainSize(node2cols.second(idset[1]));
115 r_x = db.domainSize(idset[0]);
116 r_y = db.domainSize(idset[1]);
122 if (idset.hasConditioningSet()) {
124 IdCondSet idset_xui = idset;
125 idset_xui.erase(idset[1]);
126 IdCondSet idset_yui = idset;
127 idset_yui.erase(idset[0]);
129 std::vector< double > N_ui = this->
counter_.counts(idset.conditionalIdCondSet(),
false);
130 std::vector< double > N_xui = this->
counter_.counts(idset_xui,
false);
131 std::vector< double > N_yui = this->
counter_.counts(idset_yui,
false);
133 if (informative_external_prior) {
134 this->
prior_->addConditioningPseudoCount(idset, N_ui);
135 this->
prior_->addJointPseudoCount(idset, N_xui);
136 this->
prior_->addJointPseudoCount(idset, N_yui);
144 for (
auto n_xui: N_xui)
145 score += _param_complexity_.log2Cnr(r_y, n_xui);
146 for (
auto n_yui: N_yui)
147 score += _param_complexity_.log2Cnr(r_x, n_yui);
148 for (
auto n_ui: N_ui) {
149 score -= _param_complexity_.log2Cnr(r_y, n_ui);
150 score -= _param_complexity_.log2Cnr(r_x, n_ui);
159 IdCondSet idset_xui(idset[0], this->
empty_ids_,
true);
160 IdCondSet idset_yui(idset[1], this->
empty_ids_,
true);
162 std::vector< double > N_xui = this->
counter_.counts(idset_xui,
false);
163 std::vector< double > N_yui = this->
counter_.counts(idset_yui,
false);
165 if (informative_external_prior) {
166 this->
prior_->addJointPseudoCount(idset, N_xui);
167 this->
prior_->addJointPseudoCount(idset, N_yui);
176 for (
auto n_xui: N_xui) {
177 score += _param_complexity_.log2Cnr(r_y, n_xui);
180 for (
auto n_yui: N_yui)
181 score += _param_complexity_.log2Cnr(r_x, n_yui);
182 score -= _param_complexity_.log2Cnr(r_y, N);
183 score -= _param_complexity_.log2Cnr(r_x, N);
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set.
virtual void useCache(const bool on_off)
turn on/off the use of a cache of the previously computed score
const std::vector< NodeId > empty_ids_
an empty vector
RecordCounter counter_
the record counter used for the counts over discrete variables
IndependenceTest & operator=(const IndependenceTest &from)
copy operator
virtual void clear()
clears all the data structures from memory, including the cache
Prior * prior_
the expert knowledge a priorwe add to the contingency tables
virtual void clearCache()
clears the current cache
the class for computing the NML penalty used by MIIC
KNML & operator=(const KNML &from)
copy operator
double score(const NodeId var1, const NodeId var2)
the scores
virtual double score_(const IdCondSet &idset) final
returns the score for a given IdCondSet
virtual void clear()
clears all the data structures from memory, including the C_n^r cache
const DatabaseTable & database() const
return the database used by the score
virtual void useCache(const bool on_off)
turn on/off the use of the C_n^r cache
virtual void clearCache()
clears the current C_n^r cache
const Bijection< NodeId, std::size_t > & nodeId2Columns() const
return the mapping between the columns of the database and the node ids
The class for the NML penalty used in MIIC.
The class for the NML penalty used in MIIC.
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities