mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/probability] Clip parameters
Change-Id: Ifb966b97afb15b2e876c506aff097999d012ec17
This commit is contained in:
@@ -99,7 +99,7 @@ float BinomialLaw::evaluateAtAbscissa(float x) const {
|
||||
|
||||
bool BinomialLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
if (index == 0) {
|
||||
if (x != (int)x || x < 0) {
|
||||
if (x != (int)x || x < 0.0f || x > 999.0f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -70,7 +70,7 @@ float ExponentialLaw::evaluateAtAbscissa(float x) const {
|
||||
}
|
||||
|
||||
bool ExponentialLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
if (x <= 0.0f) {
|
||||
if (x <= 0.0f || x > 7500.0f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -64,7 +64,7 @@ float PoissonLaw::evaluateAtAbscissa(float x) const {
|
||||
}
|
||||
|
||||
bool PoissonLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
if (x <= 0.0f) {
|
||||
if (x <= 0.0f || x > 999.0f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -80,9 +80,6 @@ float UniformLaw::evaluateAtAbscissa(float t) const {
|
||||
|
||||
bool UniformLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
if (index == 0) {
|
||||
if (x > m_parameter2) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (m_parameter1 > x) {
|
||||
@@ -91,6 +88,13 @@ bool UniformLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UniformLaw::setParameterAtIndex(float f, int index) {
|
||||
TwoParameterLaw::setParameterAtIndex(f, index);
|
||||
if (index == 0 && m_parameter2 < m_parameter1) {
|
||||
m_parameter2 = m_parameter1+1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float UniformLaw::cumulativeDistributiveFunctionAtAbscissa(float x) const {
|
||||
if (x < m_parameter1) {
|
||||
return 0.0f;
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
I18n::Message parameterDefinitionAtIndex(int index) override;
|
||||
float evaluateAtAbscissa(float x) const override;
|
||||
bool authorizedValueAtIndex(float x, int index) const override;
|
||||
void setParameterAtIndex(float f, int index) override;
|
||||
float cumulativeDistributiveFunctionAtAbscissa(float x) const override;
|
||||
float cumulativeDistributiveInverseForProbability(float * probability) override;
|
||||
private:
|
||||
|
||||
@@ -150,6 +150,12 @@ bool ParametersController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParametersController::textFieldDidFinishEditing(TextField * textField, const char * text) {
|
||||
FloatParameterController::textFieldDidFinishEditing(textField, text);
|
||||
m_selectableTableView.reloadData();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParametersController::buttonAction() {
|
||||
m_calculationController.setCalculationAccordingToIndex(0);
|
||||
m_calculationController.selectSubview(1);
|
||||
|
||||
@@ -24,6 +24,7 @@ private:
|
||||
float previousParameterAtIndex(int index) override;
|
||||
float parameterAtIndex(int index) override;
|
||||
bool setParameterAtIndex(int parameterIndex, float f) override;
|
||||
bool textFieldDidFinishEditing(TextField * textField, const char * text) override;
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(Responder * parentResponder, SelectableTableView * selectableTableView);
|
||||
|
||||
Reference in New Issue
Block a user