aGrUM  0.16.0
chi2.h
Go to the documentation of this file.
1 
33 #ifndef GUM_LEARNING_CHI2_H
34 #define GUM_LEARNING_CHI2_H
35 
36 #include <agrum/agrum.h>
37 #include <agrum/core/math/math.h>
38 #include <agrum/core/hashTable.h>
39 
40 #define GUM_LEARNING_CONFIDENCE_PROBA 0.05
41 
42 namespace gum {
43 
44  // =========================================================================
45  // === CHI2 CLASS ===
46  // =========================================================================
47 
58  class Chi2 {
59  public:
60  // ==========================================================================
62  // ==========================================================================
64 
70  Chi2(const std::vector< std::size_t >& var_modalities,
71  double confidence_proba = GUM_LEARNING_CONFIDENCE_PROBA);
72 
76  ~Chi2();
77 
79  // ==========================================================================
81  // ==========================================================================
83 
90  void setConditioningNodes(const std::vector< Idx >& db_conditioning_ids);
91 
98  double criticalValue(const std::pair< Idx, Idx >& pair);
99 
107  double criticalValue(Idx var1, Idx var2);
108 
114  Size degreesOfFreedom(const std::pair< Idx, Idx >& pair);
115 
122  Size degreesOfFreedom(Idx var1, Idx var2);
123 
128  void setConfidenceProba(double new_proba);
129 
147  static double probaChi2(double x, Size df);
149 
150  private:
152  const std::vector< std::size_t >& __modalities;
153 
156 
159 
162 
173  static double __criticalValue(double proba, Size df);
174 
175 
191  static double __probaZValue(double z);
192 
194  Chi2(const Chi2&) = delete;
195 
197  Chi2& operator=(const Chi2&) = delete;
198  };
199 
200 } /* namespace gum */
201 
203 #ifndef GUM_NO_INLINE
204 # include <agrum/core/math/chi2_inl.h>
205 #endif /* GUM_NO_INLINE */
206 
207 #endif /* GUM_LEARNING_CHI2_H */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void setConditioningNodes(const std::vector< Idx > &db_conditioning_ids)
Sets the conditioning nodes (useful for computing degrees of freedom).
Definition: chi2_inl.h:38
static double __criticalValue(double proba, Size df)
Computes the critical value of a given chi2 test (used by the cache).
Definition: chi2.cpp:180
double __confidence_proba
The confidence probability used for critical values.
Definition: chi2.h:155
Size __conditioning_size
The domain size of the conditioning nodes.
Definition: chi2.h:158
#define GUM_LEARNING_CONFIDENCE_PROBA
Definition: chi2.h:40
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
HashTable< Idx, double > __critical_values
A set of already computed critical values.
Definition: chi2.h:161
~Chi2()
Class destructor.
Definition: chi2.cpp:67
Represent the chi2 distribution.
Definition: chi2.h:58
Size degreesOfFreedom(const std::pair< Idx, Idx > &pair)
Returns the number of degrees of freedom.
Definition: chi2_inl.h:46
static double probaChi2(double x, Size df)
Computes the probability of chi2 value.
Definition: chi2.cpp:133
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Chi2(const std::vector< std::size_t > &var_modalities, double confidence_proba=GUM_LEARNING_CONFIDENCE_PROBA)
Default constructor.
Definition: chi2.cpp:58
void setConfidenceProba(double new_proba)
Modifies the confidence probability.
Definition: chi2_inl.h:78
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
double criticalValue(const std::pair< Idx, Idx > &pair)
Computes the critical value according to the number of degrees of freedom.
Definition: chi2_inl.h:57
Chi2 & operator=(const Chi2 &)=delete
Forbid used of the copy operator.
static double __probaZValue(double z)
Computes the probability of normal z value.
Definition: chi2.cpp:73
const std::vector< std::size_t > & __modalities
The modalities of the random variables.
Definition: chi2.h:152
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.