68 template <
typename GUM_ELEMENT >
81 template <
typename GUM_ELEMENT >
87 for (
auto attrIter =
_conTab_.attrABeginSafe(); attrIter !=
_conTab_.attrAEndSafe();
93 for (
auto valIter =
_conTab_.attrBBeginSafe(); valIter !=
_conTab_.attrBEndSafe();
96 Idx cell =
_conTab_.joint(attrIter.key(), valIter.key());
97 if (cell < 5)
continue;
100 double expected = semiExpected * (
double)valIter.val();
102 _GStat_ += 2 * cell * log(cell / expected);
110 template <
typename GUM_ELEMENT >
123 template <
typename GUM_ELEMENT >
129 template <
typename GUM_ELEMENT >
135 template <
typename GUM_ELEMENT >
140 template <
typename GUM_ELEMENT >
146 template <
typename GUM_ELEMENT >
151 template <
typename GUM_ELEMENT >
156 template <
typename GUM_ELEMENT >
161 template <
typename GUM_ELEMENT >
166 template <
typename GUM_ELEMENT >
168 return std::format(
"{}\t\t\tContingency Table : \n{}\n\t\t\tGStat : {}\n\t\t\tGStat : {}\n",
172 this->secondaryscore());
Headers of the GTestPolicy.
static double probaChi2(double x, Size df)
computes the probability of chi2 value (used by the cache)
double score() const override
Returns the performance of current variable according to the test.
bool isTestRelevant() const override
Returns true if enough observation were made so that the test can be relevant.
GTestPolicy()
Constructor.
~GTestPolicy() override
Destructor.
void addObservation(Idx iattr, GUM_ELEMENT ivalue) override
Comptabilizes the new observation.
ContingencyTable< Idx, GUM_ELEMENT > _conTab_
The contingency table used to keeps records of all observation.
std::string toString() const
double secondaryscore() const override
Returns a second criterion to severe ties.
void computeScore() const override
Computes the GStat of current variable according to the test.
void add(const GTestPolicy< GUM_ELEMENT > &src)
Performs the merging of current GTestPolicy instance with given instance.
const ContingencyTable< Idx, GUM_ELEMENT > & ct() const
Returns contingency table (needed for the merging of GTestPolicy instances).
ITestPolicy()
Allocators and Deallocators redefinition.
virtual void addObservation(Idx attr, GUM_ELEMENT value)
Comptabilizes the new observation.
virtual void computeScore() const
Recomputes the statistic from the beginning.
void add(const ITestPolicy< GUM_ELEMENT > &src)
Idx nbObservation() const
Comptabilizes the new observation.
std::string toString() const
static SmallObjectAllocator & instance()
void * allocate(const size_t &objectSize)
Allocates a block.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Size Idx
Type for indexes.
gum is the global namespace for all aGrUM entities