mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps] Probability: do not round the calculation results with 3 decimals
This commit is contained in:
committed by
EmilieNumworks
parent
07054835b4
commit
0d3d7f3587
@@ -25,10 +25,6 @@ public:
|
||||
virtual double lowerBound();
|
||||
virtual double upperBound();
|
||||
protected:
|
||||
/* Parameters in probability application are rounded to 3 decimals. This is
|
||||
* due to the limited precision of some calculation (e. g. standard normal
|
||||
* cumulative distributive function or inverse). */
|
||||
constexpr static double k_precision = 0.001;
|
||||
virtual void compute(int indexKnownElement) = 0;
|
||||
Law * m_law;
|
||||
};
|
||||
|
||||
@@ -62,8 +62,6 @@ void DiscreteCalculation::compute(int indexKnownElement) {
|
||||
return;
|
||||
}
|
||||
m_result = m_law->evaluateAtDiscreteAbscissa(m_abscissa);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,15 +43,14 @@ I18n::Message FiniteIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void FiniteIntegralCalculation::setParameterAtIndex(double f, int index) {
|
||||
assert(index >= 0 && index < 3);
|
||||
double rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
m_lowerBound = f;
|
||||
}
|
||||
if (index == 1) {
|
||||
m_upperBound = rf;
|
||||
m_upperBound = f;
|
||||
}
|
||||
if (index == 2) {
|
||||
m_result = rf;
|
||||
m_result = f;
|
||||
}
|
||||
compute(index);
|
||||
}
|
||||
@@ -83,13 +82,10 @@ void FiniteIntegralCalculation::compute(int indexKnownElement) {
|
||||
if (indexKnownElement == 2) {
|
||||
assert(m_law->type() == Law::Type::Normal);
|
||||
double p = (1.0+m_result)/2.0;
|
||||
double a = ((NormalLaw *)m_law)->cumulativeDistributiveInverseForProbability(&p);
|
||||
m_lowerBound = std::round((2.0*m_law->parameterValueAtIndex(0)-a)/k_precision)*k_precision;
|
||||
m_upperBound = std::round(a/k_precision)*k_precision;
|
||||
m_upperBound = ((NormalLaw *)m_law)->cumulativeDistributiveInverseForProbability(&p);
|
||||
m_lowerBound = 2.0*m_law->parameterValueAtIndex(0)-m_upperBound;
|
||||
}
|
||||
m_result = m_law->finiteIntegralBetweenAbscissas(m_lowerBound, m_upperBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,12 +31,11 @@ I18n::Message LeftIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void LeftIntegralCalculation::setParameterAtIndex(double f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
double rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_upperBound = rf;
|
||||
m_upperBound = f;
|
||||
}
|
||||
if (index == 1) {
|
||||
m_result = rf;
|
||||
m_result = f;
|
||||
}
|
||||
compute(index);
|
||||
}
|
||||
@@ -59,11 +58,8 @@ void LeftIntegralCalculation::compute(int indexKnownElement) {
|
||||
}
|
||||
if (indexKnownElement == 0) {
|
||||
m_result = m_law->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
} else {
|
||||
m_upperBound = m_law->cumulativeDistributiveInverseForProbability(&m_result);
|
||||
m_upperBound = std::round(m_upperBound/k_precision)*k_precision;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,11 @@ I18n::Message RightIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void RightIntegralCalculation::setParameterAtIndex(double f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
double rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
m_lowerBound = f;
|
||||
}
|
||||
if (index == 1) {
|
||||
m_result = rf;
|
||||
m_result = f;
|
||||
}
|
||||
compute(index);
|
||||
}
|
||||
@@ -59,11 +58,8 @@ void RightIntegralCalculation::compute(int indexKnownElement) {
|
||||
}
|
||||
if (indexKnownElement == 0) {
|
||||
m_result = m_law->rightIntegralFromAbscissa(m_lowerBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
} else {
|
||||
m_lowerBound = m_law->rightIntegralInverseForProbability(&m_result);
|
||||
m_lowerBound = std::round(m_lowerBound/k_precision)*k_precision;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user