65 template <
typename GUM_SCALAR >
78 template <
typename GUM_SCALAR >
82 for (
auto attrIter =
_conTab_.attrABeginSafe(); attrIter !=
_conTab_.attrAEndSafe();
85 for (
auto valIter =
_conTab_.attrBBeginSafe(); valIter !=
_conTab_.attrBEndSafe();
87 double cell = (
double)
_conTab_.joint(attrIter.key(), valIter.key());
88 if (cell < 5)
continue;
89 double expected = semiExpected * (
double)(valIter.val());
91 _chi2Score_ += std::pow(cell - expected, 2.0) / expected;
99 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
117 template <
typename GUM_SCALAR >
Headers of the Chi2TestPolicy.
ContingencyTable< Idx, GUM_SCALAR > _conTab_
The contingency table used to keeps records of all observation.
void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
void add(const Chi2TestPolicy< GUM_SCALAR > &src)
virtual double secondaryscore() const
Returns a second criterion to severe ties.
void computeScore() const
Recomputes the statistic from the beginning.
const ContingencyTable< Idx, GUM_SCALAR > & ct() const
double score() const
Returns the performance of current variable according to the test.
static double probaChi2(double x, Size df)
computes the probability of chi2 value (used by the cache)
Idx nbObservation() const
Comptabilizes the new observation.
virtual void computeScore() const
Recomputes the statistic from the beginning.
virtual void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
void add(const ITestPolicy< GUM_SCALAR > &src)
Size Idx
Type for indexes.
gum is the global namespace for all aGrUM entities