[apps/proba] Check value is ok before computing

This commit is contained in:
Léa Saviot
2019-08-26 10:14:00 +02:00
parent a650edebc7
commit 61a66f56d4
2 changed files with 10 additions and 6 deletions

View File

@@ -47,9 +47,11 @@ void LeftIntegralCalculation::compute(int indexKnownElement) {
if (indexKnownElement == 0) {
m_result = m_distribution->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
} else {
double currentResult = m_distribution->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Poincare::Preferences::LargeNumberOfSignificantDigits)) {
return;
if (!std::isnan(m_upperBound)) {
double currentResult = m_distribution->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Poincare::Preferences::LargeNumberOfSignificantDigits)) {
return;
}
}
m_upperBound = m_distribution->cumulativeDistributiveInverseForProbability(&m_result);
if (std::isnan(m_upperBound)) {

View File

@@ -47,9 +47,11 @@ void RightIntegralCalculation::compute(int indexKnownElement) {
if (indexKnownElement == 0) {
m_result = m_distribution->rightIntegralFromAbscissa(m_lowerBound);
} else {
double currentResult = m_distribution->rightIntegralFromAbscissa(m_lowerBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Poincare::Preferences::LargeNumberOfSignificantDigits)) {
return;
if (m_distribution->authorizedValueAtIndex(m_lowerBound, 0)) {
double currentResult = m_distribution->rightIntegralFromAbscissa(m_lowerBound);
if (std::fabs(currentResult - m_result) < std::pow(10.0, - Poincare::Preferences::LargeNumberOfSignificantDigits)) {
return;
}
}
m_lowerBound = m_distribution->rightIntegralInverseForProbability(&m_result);
if (std::isnan(m_lowerBound)) {