44 template <
typename GUM_SCALAR >
47 __conTab.add(iattr, ivalue);
58 template <
typename GUM_SCALAR >
62 for (
auto attrIter = __conTab.attrABeginSafe();
63 attrIter != __conTab.attrAEndSafe();
66 (
double)(attrIter.val()) / (
double)this->nbObservation();
67 for (
auto valIter = __conTab.attrBBeginSafe();
68 valIter != __conTab.attrBEndSafe();
70 double cell = (
double)__conTab.joint(attrIter.key(), valIter.key());
71 if (cell < 5)
continue;
72 double expected = semiExpected * (
double)(valIter.val());
74 __chi2Score += std::pow(cell - expected, 2.0) / expected;
82 template <
typename GUM_SCALAR >
84 if (this->_isModified()) computeScore();
88 __chi2Score, (__conTab.attrASize() - 1) * (__conTab.attrBSize() - 1));
95 template <
typename GUM_SCALAR >
97 if (this->_isModified()) computeScore();
101 template <
typename GUM_SCALAR >
104 __conTab += src.
ct();
virtual void computeScore() const
Recomputes the statistic from the beginning.
void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
virtual void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
<agrum/multidim/core/testPolicy/Chi2TestPolicy.h>
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const ContingencyTable< Idx, GUM_SCALAR > & ct() const
virtual double secondaryscore() const
Returns a second criterion to severe ties.
void add(const Chi2TestPolicy< GUM_SCALAR > &src)
void computeScore() const
Recomputes the statistic from the beginning.
static double probaChi2(double x, Size df)
computes the probability of chi2 value (used by the cache)
void add(const ITestPolicy< GUM_SCALAR > &src)
double score() const
Returns the performance of current variable according to the test.
Size Idx
Type for indexes.