Files
Upsilon/apps/probability/exponential_law.cpp
Émilie Feral 2a79d8bfd9 [apps/probability] Make law model an abstract class with inheritance for
all specific laws (binomial...)

Change-Id: Ida6d5bfb7a3fbfc288393cd2f7e9e9b934798073
2016-12-15 13:51:40 +01:00

64 lines
1.1 KiB
C++

#include "exponential_law.h"
#include <assert.h>
namespace Probability {
ExponentialLaw::ExponentialLaw(EvaluateContext * evaluateContext) :
OneParameterLaw(evaluateContext),
m_expression(Expression::parse("p1*t"))
{
//m_expression = Expression::parse("p1*exp(-p1*t)");
assert(m_expression != nullptr);
}
ExponentialLaw::~ExponentialLaw() {
delete m_expression;
}
const char * ExponentialLaw::title() {
return "Loi exponentielle";
}
Expression * ExponentialLaw::expression() const {
return m_expression;
}
Law::Type ExponentialLaw::type() const {
return Type::Exponential;
}
bool ExponentialLaw::isContinuous() {
return true;
}
const char * ExponentialLaw::parameterNameAtIndex(int index) {
assert(index == 0);
return "l";
}
const char * ExponentialLaw::parameterDefinitionAtIndex(int index) {
assert(index == 0);
return "l : parametre";
}
float ExponentialLaw::xMin() {
return 0.0f;
}
float ExponentialLaw::xMax() {
if (m_parameter1 == 0.0f) {
return 100.0f;
}
return 5.0f/m_parameter1;
}
float ExponentialLaw::yMin() {
return -0.2f;
}
float ExponentialLaw::yMax() {
return 1.0f;
}
}