Numworks Epsilon  1.4.1
Graphing Calculator Operating System
exponential_law.cpp
Go to the documentation of this file.
1 #include "exponential_law.h"
2 #include <assert.h>
3 #include <cmath>
4 #include <float.h>
5 #include <ion.h>
6 
7 namespace Probability {
8 
10  OneParameterLaw(1.0f)
11 {
12 }
13 
14 I18n::Message ExponentialLaw::title() {
15  return I18n::Message::ExponentialLaw;
16 }
17 
19  return Type::Exponential;
20 }
21 
23  return true;
24 }
25 
26 I18n::Message ExponentialLaw::parameterNameAtIndex(int index) {
27  assert(index == 0);
28  return I18n::Message::Lambda;
29 }
30 
32  assert(index == 0);
33  return I18n::Message::LambdaExponentialDefinition;
34 }
35 
37  float max = xMax();
38  return - k_displayLeftMarginRatio * max;
39 }
40 
42  assert(m_parameter1 != 0.0f);
43  float result = 5.0f/m_parameter1;
44  if (result <= 0.0f) {
45  result = 1.0f;
46  }
47  return result*(1.0f+ k_displayRightMarginRatio);
48 }
49 
52 }
53 
55  float result = m_parameter1;
56  if (result <= 0.0f || std::isnan(result)) {
57  result = 1.0f;
58  }
59  if (result <= 0.0f) {
60  result = 1.0f;
61  }
62  return result*(1.0f+ k_displayTopMarginRatio);
63 }
64 
65 float ExponentialLaw::evaluateAtAbscissa(float x) const {
66  if (x < 0.0f) {
67  return NAN;
68  }
70 }
71 
72 bool ExponentialLaw::authorizedValueAtIndex(float x, int index) const {
73  if (x <= 0.0f || x > 7500.0f) {
74  return false;
75  }
76  return true;
77 }
78 
80  return 1.0 - std::exp((double)(-m_parameter1*x));
81 }
82 
84  if (*probability >= 1.0) {
85  return INFINITY;
86  }
87  if (*probability <= 0.0) {
88  return 0.0;
89  }
90  return -std::log(1.0 - *probability)/(double)m_parameter1;
91 }
92 
93 }
#define exp(x)
Definition: math.h:176
#define NAN
Definition: math.h:30
I18n::Message title() override
#define assert(e)
Definition: assert.h:9
I18n::Message parameterDefinitionAtIndex(int index) override
static constexpr float k_displayBottomMarginRatio
Definition: law.h:45
bool isContinuous() const override
#define log(x)
Definition: math.h:184
bool authorizedValueAtIndex(float x, int index) const override
static constexpr float k_displayTopMarginRatio
Definition: law.h:44
#define isnan(x)
Definition: math.h:43
#define INFINITY
Definition: math.h:29
I18n::Message parameterNameAtIndex(int index) override
double cumulativeDistributiveInverseForProbability(double *probability) override
float evaluateAtAbscissa(float x) const override
static constexpr float k_displayRightMarginRatio
Definition: law.h:47
static constexpr float k_displayLeftMarginRatio
Definition: law.h:46
double cumulativeDistributiveFunctionAtAbscissa(double x) const override
Type type() const override