[apps/proba] Fix dome distribution behaviours for x = infinity

This commit is contained in:
Léa Saviot
2019-09-03 10:04:19 +02:00
parent 908eaa4a43
commit b712338a18
2 changed files with 7 additions and 4 deletions

View File

@@ -30,6 +30,9 @@ double StudentDistribution::cumulativeDistributiveFunctionAtAbscissa(double x) c
if (x == 0.0) {
return 0.5;
}
if (std::isinf(x)) {
return 1.0;
}
/* TODO There are some computation errors, where the probability falsly jumps to 1.
* k = 0.001 and P(x < 42000000) (for 41000000 it is around 0.5)
* k = 0.01 and P(x < 8400000) (for 41000000 it is around 0.6) */

View File

@@ -83,18 +83,18 @@ bool NormalDistribution::ExpressionParametersAreOK(bool * result, const Expressi
template<typename T>
T NormalDistribution::StandardNormalCumulativeDistributiveFunctionAtAbscissa(T abscissa) {
if (std::isnan(abscissa) || std::isinf(abscissa)) {
if (std::isnan(abscissa)) {
return NAN;
}
if (std::isinf(abscissa) || abscissa > k_boundStandardNormalDistribution) {
return (T)1.0;
}
if (abscissa == (T)0.0) {
return (T)0.5;
}
if (abscissa < (T)0.0) {
return ((T)1.0) - StandardNormalCumulativeDistributiveFunctionAtAbscissa(-abscissa);
}
if (abscissa > k_boundStandardNormalDistribution) {
return (T)1.0;
}
return ((T)0.5) + ((T)0.5) * std::erf(abscissa/std::sqrt(((T)2.0)));
}