mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/proba] Fix dome distribution behaviours for x = infinity
This commit is contained in:
@@ -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) */
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user