[apps/probability/law] Factor yMin()

This commit is contained in:
Ruben Dashyan
2019-08-01 17:55:30 +02:00
committed by Émilie Feral
parent 28b11cb367
commit ffee032e4c
12 changed files with 7 additions and 26 deletions

View File

@@ -37,10 +37,6 @@ float BinomialLaw::xMax() {
return max + k_displayRightMarginRatio*(max - min);
}
float BinomialLaw::yMin() {
return -k_displayBottomMarginRatio*yMax();
}
float BinomialLaw::yMax() {
int maxAbscissa = m_parameter2 < 1.0f ? (m_parameter1+1)*m_parameter2 : m_parameter1;
float result = evaluateAtAbscissa(maxAbscissa);

View File

@@ -12,7 +12,6 @@ public:
Type type() const override { return Type::Binomial; }
bool isContinuous() const override { return false; }
float xMin() override;
float yMin() override;
float xMax() override;
float yMax() override;
I18n::Message parameterNameAtIndex(int index) override;

View File

@@ -8,10 +8,6 @@ float ExponentialLaw::xMin() {
return - k_displayLeftMarginRatio * xMax();
}
float ExponentialLaw::yMin() {
return -k_displayBottomMarginRatio * yMax();
}
float ExponentialLaw::xMax() {
assert(m_parameter1 != 0.0f);
float result = 5.0f/m_parameter1;

View File

@@ -13,7 +13,6 @@ public:
Type type() const override { return Type::Exponential; }
bool isContinuous() const override { return true; }
float xMin() override;
float yMin() override;
float xMax() override;
float yMax() override;
I18n::Message parameterNameAtIndex(int index) override {

View File

@@ -130,4 +130,8 @@ double Law::evaluateAtDiscreteAbscissa(int k) const {
return 0.0;
}
float Law::yMin() {
return -k_displayBottomMarginRatio * yMax();
}
}

View File

@@ -41,9 +41,11 @@ protected:
static_assert(Constant::LargeNumberOfSignificantDigits == 7, "k_maxProbability is ill-defined compared to LargeNumberOfSignificantDigits");
constexpr static double k_maxProbability = 0.9999995;
constexpr static float k_displayTopMarginRatio = 0.05f;
constexpr static float k_displayBottomMarginRatio = 0.2f;
constexpr static float k_displayLeftMarginRatio = 0.05f;
constexpr static float k_displayRightMarginRatio = 0.05f;
private:
constexpr static float k_displayBottomMarginRatio = 0.2f;
float yMin() override;
};
}

View File

@@ -7,10 +7,6 @@
namespace Probability {
float NormalLaw::yMin() {
return - k_displayBottomMarginRatio * yMax();
}
float NormalLaw::yMax() {
float maxAbscissa = m_parameter1;
float result = evaluateAtAbscissa(maxAbscissa);

View File

@@ -12,7 +12,6 @@ public:
Type type() const override { return Type::Normal; }
bool isContinuous() const override { return true; }
float xMin() override { return xExtremum(true); }
float yMin() override;
float xMax() override { return xExtremum(false); }
float yMax() override;
I18n::Message parameterNameAtIndex(int index) override;

View File

@@ -9,10 +9,6 @@ float PoissonLaw::xMin() {
return -k_displayLeftMarginRatio * xMax();
}
float PoissonLaw::yMin() {
return - k_displayBottomMarginRatio * yMax();
}
float PoissonLaw::xMax() {
assert(m_parameter1 != 0);
return (m_parameter1 + 5.0f * std::sqrt(m_parameter1)) * (1.0f + k_displayRightMarginRatio);

View File

@@ -12,7 +12,6 @@ public:
Type type() const override { return Type::Poisson; }
bool isContinuous() const override { return false; }
float xMin() override;
float yMin() override;
float xMax() override;
float yMax() override;
I18n::Message parameterNameAtIndex(int index) override {

View File

@@ -32,10 +32,6 @@ float UniformLaw::xMin() {
return m_parameter1 - 0.6f * (m_parameter2 - m_parameter1);
}
float UniformLaw::yMin() {
return -k_displayBottomMarginRatio * yMax();
}
float UniformLaw::xMax() {
if (m_parameter2 - m_parameter1 < FLT_EPSILON) {
return m_parameter1 + 1.0f;

View File

@@ -12,7 +12,6 @@ public:
Type type() const override { return Type::Uniform; }
bool isContinuous() const override { return true; }
float xMin() override;
float yMin() override;
float xMax() override;
float yMax() override;
I18n::Message parameterNameAtIndex(int index) override;