53#ifndef DOXYGEN_SHOULD_SKIP_THIS
89 const std::size_t X_size,
90 const std::size_t Y_size,
91 const std::size_t Z_size,
92 const std::vector< double >& N_xyz)
const {
94 std::size_t out_size = Z_size;
95 if (node_2_marginalize == std::size_t(0)) {
96 if (Z_size != 0 && Y_size > std::numeric_limits< std::size_t >::max() / Z_size)
97 GUM_ERROR(OutOfBounds,
"marginalize_: out_size overflow (Z_size * Y_size)")
99 } else if (node_2_marginalize == std::
size_t(1)) {
100 if (Z_size != 0 && X_size > std::numeric_limits< std::size_t >::max() / Z_size)
101 GUM_ERROR(OutOfBounds,
"marginalize_: out_size overflow (Z_size * X_size)")
106 std::vector< double > res(out_size, 0.0);
109 if (node_2_marginalize == std::size_t(0)) {
110 for (std::size_t yz = std::size_t(0), xyz = std::size_t(0); yz < out_size; ++yz) {
111 for (std::size_t x = std::size_t(0); x < X_size; ++x, ++xyz) {
112 res[yz] += N_xyz[xyz];
115 }
else if (node_2_marginalize == std::size_t(1)) {
116 for (std::size_t z = std::size_t(0), xyz = std::size_t(0), beg_xz = std::size_t(0);
118 ++z, beg_xz += X_size) {
119 for (std::size_t y = std::size_t(0); y < Y_size; ++y) {
120 for (std::size_t x = std::size_t(0), xz = beg_xz; x < X_size; ++x, ++xz, ++xyz) {
121 res[xz] += N_xyz[xyz];
125 }
else if (node_2_marginalize == std::size_t(2)) {
126 const std::size_t XY_size = X_size * Y_size;
127 for (std::size_t z = std::size_t(0), xyz = std::size_t(0); z < out_size; ++z) {
128 for (std::size_t xy = std::size_t(0); xy < XY_size; ++xy, ++xyz) {
129 res[z] += N_xyz[xyz];
134 "_marginalize not implemented for nodeset " << node_2_marginalize);
CachedContingencyCounter & operator=(const CachedContingencyCounter &from)
copy operator
The base class for all the independence tests used for learning.
std::vector< std::size_t > _domain_sizes_
the domain sizes of the variables (indexed by column id in the database)
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
IndependenceTest & operator=(const IndependenceTest &from)
copy operator
#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