mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/probability] Comments to explain the 0.001 precision is proba
Change-Id: Id5618802f9a08967b2fa0d68b35ff2a4f0b5a116
This commit is contained in:
@@ -17,6 +17,9 @@ public:
|
||||
virtual float lowerBound();
|
||||
virtual float 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 float k_precision = 0.001f;
|
||||
virtual void compute(int indexKnownElement) = 0;
|
||||
Law * m_law;
|
||||
|
||||
@@ -32,7 +32,6 @@ const char * FiniteIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void FiniteIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 3);
|
||||
/* Parameters in probability application are rounder to 3 decimals */
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
|
||||
@@ -28,7 +28,6 @@ const char * LeftIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void LeftIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
/* Parameters in probability application are rounder to 3 decimals */
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_upperBound = rf;
|
||||
|
||||
@@ -28,7 +28,6 @@ const char * RightIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void RightIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
/* Parameters in probability application are rounder to 3 decimals */
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
|
||||
@@ -107,6 +107,7 @@ float NormalLaw::standardNormalCumulativeDistributiveFunctionAtAbscissa(float ab
|
||||
if (abscissa > k_boundStandardNormalDistribution) {
|
||||
return 1.0f;
|
||||
}
|
||||
/* Waissi & Rossin's formula (error less than 0.0001) */
|
||||
return 1.0f/(1.0f+expf(-sqrtf(M_PI)*(k_beta1*powf(abscissa,5)+k_beta2*powf(abscissa,3)+k_beta3*abscissa)));
|
||||
}
|
||||
|
||||
@@ -120,6 +121,7 @@ float NormalLaw::standardNormalCumulativeDistributiveInverseForProbability(float
|
||||
if (probability < 0.5f) {
|
||||
return -standardNormalCumulativeDistributiveInverseForProbability(1-probability);
|
||||
}
|
||||
/* Soranzo & Epure (error less than 0.001) */
|
||||
return (k_alpha3/logf(k_alpha2))*logf(1.0f - logf(-logf(probability)/logf(2.0f))/logf(k_alpha1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user