54#ifndef DOXYGEN_SHOULD_SKIP_THIS
59# define GUM_CHI_EPSILON 0.000001
60# define GUM_CHI_MAX 99999.0
61# define GUM_LOG_SQRT_PI 0.5723649429247000870717135
62# define GUM_I_SQRT_PI 0.5641895835477562869480795
64# define _gum_ex(x) (((x) < -GUM_BIGX) ? 0.0 : std::exp(x))
75 if (z == 0.0) x = 0.0;
77 y = 0.5 * std::fabs(z);
79 if (y >= (GUM_Z_MAX * 0.5)) x = 1.0;
82 x = ((((((((0.000124818987 * w - 0.001075204047) * w + 0.005198775019) * w - 0.019198292004)
96 x = (((((((((((((-0.000045255659 * y + 0.000152529290) * y - 0.000019538132) * y
123 return (z > 0.0 ? ((x + 1.0) * 0.5) : ((1.0 - x) * 0.5));
132 if ((x <= 0.0) || (df < 1))
return (1.0);
136 even = (2 * (df / 2)) == df;
138 if (df > 1) y = _gum_ex(-a);
143 x = 0.5 * (df - 1.0);
144 z = (even ? 1.0 : 0.5);
147 e = (even ? 0.0 : GUM_LOG_SQRT_PI);
152 s += _gum_ex(c * z - a - e);
158 e = (even ? 1.0 : (GUM_I_SQRT_PI / std::sqrt(a)));
174 double minchisq = 0.0;
175 double maxchisq = GUM_CHI_MAX;
178 if (df == 0)
return (0.0);
180 if (proba <= 0.0)
return (maxchisq);
181 else if (proba >= 1.0)
return (0.0);
183 chisqval = df / std::sqrt(proba);
185 while (maxchisq - minchisq > GUM_CHI_EPSILON) {
186 if (
probaChi2(chisqval, df) < proba) maxchisq = chisqval;
187 else minchisq = chisqval;
189 chisqval = (maxchisq + minchisq) * 0.5;
The class that represents the chi2 distribution.
static double criticalValue(double proba, Size df)
Computes the critical chi2 value for a given confidence probability and number of degrees of freedom.
static double _probaZValue_(double z)
Computes the probability of normal z value.
static double probaChi2(double x, Size df)
Computes the probability of chi2 value.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
gum is the global namespace for all aGrUM entities