Numworks Epsilon  1.4.1
Graphing Calculator Operating System
law.h
Go to the documentation of this file.
1 #ifndef PROBABILITE_LAW_H
2 #define PROBABILITE_LAW_H
3 
4 #include <poincare.h>
5 #include <escher.h>
6 #include "../../constant.h"
7 #include "../../shared/curve_view_range.h"
8 #include "../../i18n.h"
9 
10 namespace Probability {
11 
12 class Law : public Shared::CurveViewRange {
13 public:
14  Law();
15  enum class Type : uint8_t{
16  Binomial,
17  Uniform,
19  Normal,
20  Poisson
21  };
22  virtual ~Law() = default;
23  virtual I18n::Message title() = 0;
24  virtual Type type() const = 0;
25  virtual bool isContinuous() const = 0;
26  float xGridUnit() override;
27  virtual int numberOfParameter() = 0;
28  virtual float parameterValueAtIndex(int index) = 0;
29  virtual I18n::Message parameterNameAtIndex(int index) = 0;
30  virtual I18n::Message parameterDefinitionAtIndex(int index) = 0;
31  virtual void setParameterAtIndex(float f, int index) = 0;
32  virtual float evaluateAtAbscissa(float x) const = 0;
33  virtual bool authorizedValueAtIndex(float x, int index) const = 0;
34  virtual double cumulativeDistributiveFunctionAtAbscissa(double x) const;
35  double rightIntegralFromAbscissa(double x) const;
36  double finiteIntegralBetweenAbscissas(double a, double b) const;
37  virtual double cumulativeDistributiveInverseForProbability(double * probability);
38  virtual double rightIntegralInverseForProbability(double * probability);
39  virtual double evaluateAtDiscreteAbscissa(int k) const;
40  constexpr static int k_maxNumberOfOperations = 1000000;
41 protected:
42  static_assert(Constant::LargeNumberOfSignificantDigits == 7, "k_maxProbability is ill-defined compared to LargeNumberOfSignificantDigits");
43  constexpr static double k_maxProbability = 0.9999995;
44  constexpr static float k_displayTopMarginRatio = 0.05f;
45  constexpr static float k_displayBottomMarginRatio = 0.2f;
46  constexpr static float k_displayLeftMarginRatio = 0.05f;
47  constexpr static float k_displayRightMarginRatio = 0.05f;
48 };
49 
50 }
51 
52 #endif
virtual bool isContinuous() const =0
virtual ~Law()=default
virtual I18n::Message parameterNameAtIndex(int index)=0
virtual I18n::Message title()=0
virtual void setParameterAtIndex(float f, int index)=0
double finiteIntegralBetweenAbscissas(double a, double b) const
Definition: law.cpp:44
static constexpr float k_displayBottomMarginRatio
Definition: law.h:45
virtual double rightIntegralInverseForProbability(double *probability)
Definition: law.cpp:101
unsigned char uint8_t
Definition: stdint.h:4
virtual int numberOfParameter()=0
virtual float parameterValueAtIndex(int index)=0
virtual double cumulativeDistributiveInverseForProbability(double *probability)
Definition: law.cpp:68
static constexpr double k_maxProbability
Definition: law.h:43
virtual Type type() const =0
static constexpr int LargeNumberOfSignificantDigits
Definition: constant.h:6
static constexpr float k_displayTopMarginRatio
Definition: law.h:44
virtual float evaluateAtAbscissa(float x) const =0
virtual double cumulativeDistributiveFunctionAtAbscissa(double x) const
Definition: law.cpp:16
virtual I18n::Message parameterDefinitionAtIndex(int index)=0
double rightIntegralFromAbscissa(double x) const
Definition: law.cpp:37
virtual double evaluateAtDiscreteAbscissa(int k) const
Definition: law.cpp:134
float xGridUnit() override
Definition: law.cpp:12
static constexpr float k_displayRightMarginRatio
Definition: law.h:47
static constexpr float k_displayLeftMarginRatio
Definition: law.h:46
static constexpr int k_maxNumberOfOperations
Definition: law.h:40
virtual bool authorizedValueAtIndex(float x, int index) const =0