mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/proba] Fix result consistency
Scenario: Poisson distribution, lambda = 4, P(x < ?) = 1.3E-112
This commit is contained in:
@@ -50,10 +50,12 @@ void LeftIntegralCalculation::compute(int indexKnownElement) {
|
||||
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)) {
|
||||
m_result = currentResult;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_upperBound = m_distribution->cumulativeDistributiveInverseForProbability(&m_result);
|
||||
m_result = m_distribution->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
|
||||
if (std::isnan(m_upperBound)) {
|
||||
m_result = NAN;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,12 @@ void RightIntegralCalculation::compute(int indexKnownElement) {
|
||||
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)) {
|
||||
m_result = currentResult;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_lowerBound = m_distribution->rightIntegralInverseForProbability(&m_result);
|
||||
m_result = m_distribution->rightIntegralFromAbscissa(m_lowerBound);
|
||||
if (std::isnan(m_lowerBound)) {
|
||||
m_result = NAN;
|
||||
}
|
||||
|
||||
@@ -49,14 +49,14 @@ double Distribution::finiteIntegralBetweenAbscissas(double a, double b) const {
|
||||
}
|
||||
|
||||
double Distribution::cumulativeDistributiveInverseForProbability(double * probability) {
|
||||
if (*probability >= 1.0) {
|
||||
if (*probability > 1.0 - DBL_EPSILON) {
|
||||
return INFINITY;
|
||||
}
|
||||
if (isContinuous()) {
|
||||
return 0.0;
|
||||
}
|
||||
if (*probability <= 0.0) {
|
||||
return 0.0;
|
||||
if (*probability < DBL_EPSILON) {
|
||||
return -1.0;
|
||||
}
|
||||
return Poincare::Solver::CumulativeDistributiveInverseForNDefinedFunction<double>(probability,
|
||||
[](double k, Poincare::Context * context, Poincare::Preferences::ComplexFormat complexFormat, Poincare::Preferences::AngleUnit angleUnit, const void * context1, const void * context2, const void * context3) {
|
||||
|
||||
@@ -208,7 +208,7 @@ Coordinate2D<double> Solver::IncreasingFunctionRoot(double ax, double bx, double
|
||||
template<typename T>
|
||||
T Solver::CumulativeDistributiveInverseForNDefinedFunction(T * probability, ValueAtAbscissa evaluation, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, const void * context1, const void * context2, const void * context3) {
|
||||
T precision = sizeof(T) == sizeof(double) ? DBL_EPSILON : FLT_EPSILON;
|
||||
assert(*probability <= (((T)1.0) - precision) && *probability > precision);
|
||||
assert(*probability <= (((T)1.0) - precision) && *probability >= precision);
|
||||
T p = 0.0;
|
||||
int k = 0;
|
||||
T delta = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user