[apps/probability] Initial Fisher distribution

This commit is contained in:
Léa Saviot
2020-01-10 16:28:16 +01:00
parent 08cdf5a8d2
commit 93c96186c4
14 changed files with 128 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ app_headers += apps/probability/app.h
app_probability_test_src = $(addprefix apps/probability/,\
distribution/binomial_distribution.cpp \
distribution/chi_squared_distribution.cpp \
distribution/fisher_distribution.cpp \
distribution/geometric_distribution.cpp \
distribution/helper.cpp \
distribution/distribution.cpp \
@@ -64,9 +65,11 @@ $(eval $(call depends_on_image,apps/probability/distribution_controller.cpp,$(ad
binomial_icon.png \
chi_squared_icon.png \
exponential_icon.png \
fisher_icon.png \
focused_binomial_icon.png \
focused_chi_squared_icon.png \
focused_exponential_icon.png \
focused_fisher_icon.png \
focused_geometric_icon.png \
focused_normal_icon.png \
focused_poisson_icon.png \

View File

@@ -12,6 +12,7 @@ GeometricDistribution = "Geometrischeverteilung"
PoissonDistribution = "Poisson-Verteilung"
ChiSquaredDistribution = "Chi-Quadrat-Verteilung"
StudentDistribution = "Student-Verteilung"
FisherDistribution = "F-Verteilung"
ChooseParameters = "Parameter auswählen"
RepetitionNumber = "n: Anzahl der Versuche"
SuccessProbability = "p: Erfolgswahrscheinlichkeit"
@@ -21,4 +22,6 @@ MeanDefinition = "μ: Erwartungswert"
DeviationDefinition = "σ: Standardabweichung"
LambdaPoissonDefinition = "λ: Parameter"
DegreesOfFreedomDefinition = "k: Anzahl der Freiheitsgrade"
D1FisherDefinition = "d1: Freiheitsgrade des Zählers"
D2FisherDefinition = "d2: Freiheitsgrade des Nenners"
ComputeProbability = "Wahrscheinlichkeit berechnen"

View File

@@ -12,6 +12,7 @@ GeometricDistribution = "Geometric distribution"
PoissonDistribution = "Poisson distribution"
ChiSquaredDistribution = "Chi-squared distribution"
StudentDistribution = "Student's distribution"
FisherDistribution = "F distribution"
ChooseParameters = "Choose parameters"
RepetitionNumber = "n: Number of trials"
SuccessProbability = "p: Success probability"
@@ -21,4 +22,6 @@ MeanDefinition = "μ: Mean"
DeviationDefinition = "σ: Standard deviation"
LambdaPoissonDefinition = "λ: Parameter"
DegreesOfFreedomDefinition = "k: Degrees of freedom"
D1FisherDefinition = "d1: Degrees of freedom of the numerator"
D2FisherDefinition = "d2: Degrees of freedom of the denominator"
ComputeProbability = "Calculate probabilities"

View File

@@ -12,6 +12,7 @@ GeometricDistribution = "Distribución geométrica"
PoissonDistribution = "Distribución de Poisson"
ChiSquaredDistribution = "Distribución chi-cuadrado"
StudentDistribution = "Distribución de Student"
FisherDistribution = "Distribución F"
ChooseParameters = "Seleccionar parámetros"
RepetitionNumber = "n : Número de ensayos "
SuccessProbability = "p : Probabilidad de éxito "
@@ -21,4 +22,6 @@ MeanDefinition = "μ : Media"
DeviationDefinition = "σ : Desviación típica"
LambdaPoissonDefinition = "λ : Parámetro"
DegreesOfFreedomDefinition = "k : Grados de libertad"
D1FisherDefinition = "d1 : Grados de libertad del numerador"
D2FisherDefinition = "d2 : Grados de libertad del denominador"
ComputeProbability = "Calcular las probabilidades"

View File

@@ -12,6 +12,7 @@ GeometricDistribution = "Loi géométrique"
PoissonDistribution = "Loi de Poisson"
ChiSquaredDistribution = "Loi du chi2"
StudentDistribution = "Loi de Student"
FisherDistribution = "Loi de Fisher"
ChooseParameters = "Choisir les paramètres"
RepetitionNumber = "n : Nombre de répétitions"
SuccessProbability = "p : Probabilité de succès"
@@ -21,4 +22,6 @@ MeanDefinition = "μ : Espérance ou moyenne"
DeviationDefinition = "σ : Écart type"
LambdaPoissonDefinition = "λ : Paramètre"
DegreesOfFreedomDefinition = "k : Degrés de liberté"
D1FisherDefinition = "d1 : Degrés de liberté du numérateur"
D2FisherDefinition = "d2 : Degrés de liberté du dénominateur"
ComputeProbability = "Calculer les probabilités"

View File

@@ -12,6 +12,7 @@ GeometricDistribution = "Distribuição geométrica"
PoissonDistribution = "Distribuição de Poisson"
ChiSquaredDistribution = "Distribuição qui-quadrado"
StudentDistribution = "Distribuição de Student"
FisherDistribution = "Distribuição F"
ChooseParameters = "Selecionar os parâmetros"
RepetitionNumber = "n : Número de ensaios"
SuccessProbability = "p : Probabilidade de sucesso"
@@ -21,4 +22,6 @@ MeanDefinition = "μ : Média"
DeviationDefinition = "σ : Desvio padrão"
LambdaPoissonDefinition = "λ : Parâmetro"
DegreesOfFreedomDefinition = "k : Graus de liberdade"
D1FisherDefinition = "d1 : Graus de liberdade do numerador"
D2FisherDefinition = "d2 : Graus de liberdade do denominador"
ComputeProbability = "Calcular probabilidades"

View File

@@ -1,6 +1,9 @@
D1 = "d1"
D2 = "d2"
DiscreteLegend = "P(X="
FiniteIntegralFirstLegend = "P("
FiniteIntegralLegend = "≤X≤"
Fisher = "Fisher"
LeftIntegralFirstLegend = "P(X≤"
LeftIntegralSecondLegend = ")="
Poisson = "Poisson"

View File

@@ -18,7 +18,8 @@ public:
ChiSquared,
Student,
Geometric,
Poisson
Poisson,
Fisher
};
virtual ~Distribution() = default;
virtual I18n::Message title() = 0;

View File

@@ -0,0 +1,63 @@
#include "fisher_distribution.h"
#include <poincare/normal_distribution.h>
#include <cmath>
#include <float.h>
namespace Probability {
float FisherDistribution::xMin() const {
return -k_displayLeftMarginRatio * xMax();
}
float FisherDistribution::xMax() const {
return 10.0f; //TODO LEA
}
float FisherDistribution::yMax() const {
float maxAbscissa = m_parameter1;
float result = evaluateAtAbscissa(maxAbscissa);
if (std::isnan(result) || result <= 0.0f) {
result = 1.0f;
}
return 1.0f; //TODO LEA
}
I18n::Message FisherDistribution::parameterNameAtIndex(int index) {
if (index == 0) {
return I18n::Message::D1;
}
assert(index == 1);
return I18n::Message::D2;
}
I18n::Message FisherDistribution::parameterDefinitionAtIndex(int index) {
if (index == 0) {
return I18n::Message::D1FisherDefinition;
}
assert(index == 1);
return I18n::Message::D2FisherDefinition;
}
float FisherDistribution::evaluateAtAbscissa(float x) const {
return 1.0; //TODO LEA Poincare::FisherDistribution::EvaluateAtAbscissa(x, m_parameter1, m_parameter2);
}
bool FisherDistribution::authorizedValueAtIndex(float x, int index) const {
assert(index == 0 || index == 1);
return x > FLT_MIN; // TODO LEA Add max limit? See NormalDistribution
}
void FisherDistribution::setParameterAtIndex(float f, int index) {
TwoParameterDistribution::setParameterAtIndex(f, index);
// TODO LEA Adjust parameter if max definition ? See NormalDistribution
}
double FisherDistribution::cumulativeDistributiveFunctionAtAbscissa(double x) const {
return 1.0; //TODO LEA
}
double FisherDistribution::cumulativeDistributiveInverseForProbability(double * probability) {
return 1.0; //TODO LEA
}
}

View File

@@ -0,0 +1,28 @@
#ifndef PROBABILITE_FISHER_DISTRIBUTION_H
#define PROBABILITE_FISHER_DISTRIBUTION_H
#include "two_parameter_distribution.h"
namespace Probability {
class FisherDistribution final : public TwoParameterDistribution {
public:
FisherDistribution() : TwoParameterDistribution(1.0f, 1.0f) {}
I18n::Message title() override { return I18n::Message::FisherDistribution; }
Type type() const override { return Type::Fisher; }
bool isContinuous() const override { return true; }
float xMin() const override;
float xMax() const override;
float yMax() const override;
I18n::Message parameterNameAtIndex(int index) override;
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;
double cumulativeDistributiveFunctionAtAbscissa(double x) const override;
double cumulativeDistributiveInverseForProbability(double * probability) override;
};
}
#endif

View File

@@ -5,6 +5,7 @@
#include "distribution/binomial_distribution.h"
#include "distribution/chi_squared_distribution.h"
#include "distribution/exponential_distribution.h"
#include "distribution/fisher_distribution.h"
#include "distribution/geometric_distribution.h"
#include "distribution/normal_distribution.h"
#include "distribution/poisson_distribution.h"
@@ -13,6 +14,7 @@
#include "images/binomial_icon.h"
#include "images/chi_squared_icon.h"
#include "images/exponential_icon.h"
#include "images/fisher_icon.h"
#include "images/geometric_icon.h"
#include "images/normal_icon.h"
#include "images/poisson_icon.h"
@@ -21,6 +23,7 @@
#include "images/focused_binomial_icon.h"
#include "images/focused_chi_squared_icon.h"
#include "images/focused_exponential_icon.h"
#include "images/focused_fisher_icon.h"
#include "images/focused_geometric_icon.h"
#include "images/focused_normal_icon.h"
#include "images/focused_poisson_icon.h"
@@ -61,7 +64,8 @@ static I18n::Message sMessages[] = {
I18n::Message::ChiSquared,
I18n::Message::Student,
I18n::Message::Geometric,
I18n::Message::Poisson
I18n::Message::Poisson,
I18n::Message::Fisher
};
DistributionController::DistributionController(Responder * parentResponder, Distribution * distribution, ParametersController * parametersController) :
@@ -129,7 +133,8 @@ void Probability::DistributionController::willDisplayCellForIndex(HighlightCell
ImageStore::ChiSquaredIcon,
ImageStore::StudentIcon,
ImageStore::GeometricIcon,
ImageStore::PoissonIcon
ImageStore::PoissonIcon,
ImageStore::FisherIcon
};
const Image * focusedImages[k_totalNumberOfModels] = {
ImageStore::FocusedBinomialIcon,
@@ -139,7 +144,8 @@ void Probability::DistributionController::willDisplayCellForIndex(HighlightCell
ImageStore::FocusedChiSquaredIcon,
ImageStore::FocusedStudentIcon,
ImageStore::FocusedGeometricIcon,
ImageStore::FocusedPoissonIcon
ImageStore::FocusedPoissonIcon,
ImageStore::FocusedFisherIcon
};
myCell->setImage(images[index], focusedImages[index]);
myCell->reloadCell();
@@ -179,7 +185,9 @@ void Probability::DistributionController::setDistributionAccordingToIndex(int in
case 7:
new(m_distribution) PoissonDistribution();
break;
case 8:
new(m_distribution) FisherDistribution();
break;
default:
return;
}

View File

@@ -34,8 +34,8 @@ private:
SelectableTableView * m_selectableTableView;
};
void setDistributionAccordingToIndex(int index);
constexpr static int k_totalNumberOfModels = 8;
Cell m_cells[k_totalNumberOfModels];
constexpr static int k_totalNumberOfModels = 9;
Cell m_cells[k_totalNumberOfModels]; // TODO LEA replace with number of visible cells
SelectableTableView m_selectableTableView;
ContentView m_contentView;
I18n::Message * m_messages;

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B