Numworks Epsilon  1.4.1
Graphing Calculator Operating System
right_integral_calculation.cpp
Go to the documentation of this file.
2 #include <assert.h>
3 #include <ion.h>
4 #include <cmath>
5 
6 namespace Probability {
7 
9  Calculation(),
10  m_lowerBound(0.0),
11  m_result(0.0)
12 {
13  compute(0);
14 }
15 
17  return Type::RightIntegral;
18 }
19 
21  return 2;
22 }
23 
25  assert(index >= 0 && index < 2);
26  if (index == 0) {
27  return I18n::Message::RightIntegralFirstLegend;
28  }
29  return I18n::Message::RightIntegralSecondLegend;
30 }
31 
33  assert(index >= 0 && index < 2);
34  if (index == 0) {
35  m_lowerBound = f;
36  }
37  if (index == 1) {
38  m_result = f;
39  }
40  compute(index);
41 }
42 
44  assert(index >= 0 && index < 2);
45  if (index == 0) {
46  return m_lowerBound;
47  }
48  return m_result;
49 }
50 
52  return m_lowerBound;
53 }
54 
55 void RightIntegralCalculation::compute(int indexKnownElement) {
56  if (m_law == nullptr) {
57  return;
58  }
59  if (indexKnownElement == 0) {
60  m_result = m_law->rightIntegralFromAbscissa(m_lowerBound);
61  } else {
62  m_lowerBound = m_law->rightIntegralInverseForProbability(&m_result);
63  }
64 }
65 
66 }
I18n::Message legendForParameterAtIndex(int index) override
#define assert(e)
Definition: assert.h:9
virtual double rightIntegralInverseForProbability(double *probability)
Definition: law.cpp:101
void setParameterAtIndex(double f, int index) override
double rightIntegralFromAbscissa(double x) const
Definition: law.cpp:37