aGrUM  0.14.2
chiSquare.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 #ifndef GUM_CHI_SQUARE_H
29 # define GUM_CHI_SQUARE_H
30 
31 # include <agrum/core/math/math.h>
32 # include <agrum/core/hashTable.h>
33 
34 
35 namespace gum {
36 
45  class ChiSquare {
46  public:
47  static double probaChi2(double x, Size df);
48 
49  private:
52 
54  static constexpr double __Z_MAX = 6.0;
55 
57  static constexpr double __CHI_EPSILON = 0.000001;
58 
60  static constexpr double __CHI_MAX = 99999.0;
61 
63  static constexpr double __LOG_SQRT_PI = 0.5723649429247000870717135;
64 
66  static constexpr double __I_SQRT_PI = 0.5641895835477562869480795;
67 
69  static constexpr double __BIGX = 20.0;
70 
72 
73 
76 
77  static double __exp(double x) { return (((x) < -__BIGX) ? 0.0 : exp(x)); }
78 
79  static double __probaZValue(double z);
81  };
82 
83 } /* namespace gum */
84 
85 #endif // GUM_CHI_SQUARE_H
86 
87 
88 // static HashTable<std::pair<double, unsigned long>, double> __chi2Cache;
89 // static HashTable<double, double> __ZCache;
90 // static Idx nbZ;
91 // static Idx nbChi;
92 // static Idx nbZt;
93 // static Idx nbChit;
Useful macros for maths.
static constexpr double __LOG_SQRT_PI
log (sqrt (pi))
Definition: chiSquare.h:63
static constexpr double __BIGX
max value to represent exp (x)
Definition: chiSquare.h:69
static double __probaZValue(double z)
computes the probability of normal z value (used by the cache)
Definition: chiSquare.cpp:40
static double __exp(double x)
Required constant to compute the cdf.
Definition: chiSquare.h:77
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
static constexpr double __I_SQRT_PI
1 / sqrt (pi)
Definition: chiSquare.h:66
static constexpr double __Z_MAX
Required constant to compute the cdf.
Definition: chiSquare.h:54
static constexpr double __CHI_MAX
maximum chi square value
Definition: chiSquare.h:60
static double probaChi2(double x, Size df)
computes the probability of chi2 value (used by the cache)
Definition: chiSquare.cpp:115
static constexpr double __CHI_EPSILON
accuracy of critchi approximation
Definition: chiSquare.h:57
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Class hash tables iterators.
<agrum/FMDP/learning/core/testPolicy/chiSquare.h>
Definition: chiSquare.h:45