[apps/proba] More seamless computation

If the user computes P(x<a) which gives b, then presses OK on b, return
a.
This prevents some comutation errors such as for student distribution
with 0.05 degrees of freedom, P(x<9900000) then press ok on the result
This commit is contained in:
Léa Saviot
2019-08-19 15:46:38 +02:00
parent 56543e8886
commit 7ec6bea991
2 changed files with 8 additions and 0 deletions

View File

@@ -47,6 +47,10 @@ void LeftIntegralCalculation::compute(int indexKnownElement) {
if (indexKnownElement == 0) {
m_result = m_law->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
} else {
double currentResult = m_law->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Constant::LargeNumberOfSignificantDigits)) {
return;
}
m_upperBound = m_law->cumulativeDistributiveInverseForProbability(&m_result);
}
}

View File

@@ -47,6 +47,10 @@ void RightIntegralCalculation::compute(int indexKnownElement) {
if (indexKnownElement == 0) {
m_result = m_law->rightIntegralFromAbscissa(m_lowerBound);
} else {
double currentResult = m_law->rightIntegralFromAbscissa(m_lowerBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Constant::LargeNumberOfSignificantDigits)) {
return;
}
m_lowerBound = m_law->rightIntegralInverseForProbability(&m_result);
}
}