41 template <
typename GUM_SCALAR >
44 __conTab.add(iattr, ivalue);
55 template <
typename GUM_SCALAR >
59 for (
auto attrIter = __conTab.attrABeginSafe();
60 attrIter != __conTab.attrAEndSafe();
63 (
double)(attrIter.val()) / (
double)this->nbObservation();
64 for (
auto valIter = __conTab.attrBBeginSafe();
65 valIter != __conTab.attrBEndSafe();
67 double cell = (
double)__conTab.joint(attrIter.key(), valIter.key());
68 if (cell < 5)
continue;
69 double expected = semiExpected * (
double)(valIter.val());
71 __chi2Score += std::pow(cell - expected, 2.0) / expected;
79 template <
typename GUM_SCALAR >
81 if (this->_isModified()) computeScore();
85 __chi2Score, (__conTab.attrASize() - 1) * (__conTab.attrBSize() - 1));
92 template <
typename GUM_SCALAR >
94 if (this->_isModified()) computeScore();
98 template <
typename GUM_SCALAR >
101 __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.
gum is the global namespace for all aGrUM entities
<agrum/multidim/core/testPolicy/Chi2TestPolicy.h>
Headers of the Chi2TestPolicy.
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.