51#ifndef DOXYGEN_SHOULD_SKIP_THIS
65 Prior* new_prior = from.prior_->clone();
66 RecordCounter new_counter = from.counter_;
67 ScoringCache new_cache = from.cache_;
73 cache_ = std::move(new_cache);
83 std::swap(
prior_, from.prior_);
86 cache_ = std::move(from.cache_);
100 const std::vector< std::pair< std::size_t, std::size_t > >& new_ranges) {
101 std::vector< std::pair< std::size_t, std::size_t > > old_ranges =
ranges();
108 std::vector< std::pair< std::size_t, std::size_t > > old_ranges =
ranges();
120 const std::size_t X_size,
121 const std::size_t Y_size,
122 const std::size_t Z_size,
123 const std::vector< double >& N_xyz)
const {
125 std::size_t out_size = Z_size;
126 if (node_2_marginalize == std::size_t(0)) out_size *= Y_size;
127 else if (node_2_marginalize == std::size_t(1)) out_size *= X_size;
130 std::vector< double > res(out_size, 0.0);
133 if (node_2_marginalize == std::size_t(0)) {
134 for (std::size_t yz = std::size_t(0), xyz = std::size_t(0); yz < out_size; ++yz) {
135 for (std::size_t x = std::size_t(0); x < X_size; ++x, ++xyz) {
136 res[yz] += N_xyz[xyz];
139 }
else if (node_2_marginalize == std::size_t(1)) {
140 for (std::size_t z = std::size_t(0), xyz = std::size_t(0), beg_xz = std::size_t(0);
142 ++z, beg_xz += X_size) {
143 for (std::size_t y = std::size_t(0); y < Y_size; ++y) {
144 for (std::size_t x = std::size_t(0), xz = beg_xz; x < X_size; ++x, ++xz, ++xyz) {
145 res[xz] += N_xyz[xyz];
149 }
else if (node_2_marginalize == std::size_t(2)) {
150 const std::size_t XY_size = X_size * Y_size;
151 for (std::size_t z = std::size_t(0), xyz = std::size_t(0); z < out_size; ++z) {
152 for (std::size_t xy = std::size_t(0); xy < XY_size; ++xy, ++xyz) {
153 res[z] += N_xyz[xyz];
158 "_marginalize not implemented for nodeset " << node_2_marginalize);
The base class for all the independence tests used for learning.
std::vector< double > marginalize_(const std::size_t node_2_marginalize, const std::size_t X_size, const std::size_t Y_size, const std::size_t Z_size, const std::vector< double > &N_xyz) const
returns a counting vector where variables are marginalized from N_xyz
void setRanges(const std::vector< std::pair< std::size_t, std::size_t > > &new_ranges)
sets new ranges to perform the counts used by the independence test
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
bool use_cache_
a Boolean indicating whether we wish to use the cache
void clearRanges()
reset the ranges to the one range corresponding to the whole database
ScoringCache cache_
the scoring cache
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
#define GUM_ERROR(type, msg)
the base class for all the independence tests used for learning
the base class for all the independence tests used for learning
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities