mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/probability] Define the Student distribution
This commit is contained in:
committed by
Léa Saviot
parent
386ca7f1d6
commit
ddf9dc222b
@@ -23,6 +23,7 @@ app_probability_src = $(addprefix apps/probability/,\
|
||||
law/exponential_law.cpp \
|
||||
law/normal_law.cpp \
|
||||
law/poisson_law.cpp \
|
||||
law/student_law.cpp \
|
||||
law/two_parameter_law.cpp \
|
||||
law/uniform_law.cpp \
|
||||
law_controller.cpp \
|
||||
|
||||
@@ -6,12 +6,14 @@ Uniforme = "Uniform"
|
||||
Normal = "Normal"
|
||||
Poisson = "Poisson"
|
||||
ChiSquared = "Chi-Quadrat"
|
||||
Student = "Student"
|
||||
BinomialLaw = "Binomialverteilung"
|
||||
UniformLaw = "Uniformverteilung"
|
||||
ExponentialLaw = "Exponentialverteilung"
|
||||
NormalLaw = "Normalverteilung"
|
||||
PoissonLaw = "Poisson-Verteilung"
|
||||
ChiSquaredLaw = "Chi-Quadrat-Verteilung"
|
||||
StudentLaw = "Student-Verteilung"
|
||||
ChooseParameters = "Parameter auswählen"
|
||||
RepetitionNumber = "n: Anzahl der Versuche"
|
||||
SuccessProbability = "p: Erfolgswahrscheinlichkeit"
|
||||
|
||||
@@ -6,12 +6,14 @@ Uniforme = "Uniform"
|
||||
Normal = "Normal"
|
||||
Poisson = "Poisson"
|
||||
ChiSquared = "Chi-squared"
|
||||
Student = "Student"
|
||||
BinomialLaw = "Binomial distribution"
|
||||
UniformLaw = "Uniform distribution"
|
||||
ExponentialLaw = "Exponential distribution"
|
||||
NormalLaw = "Normal distribution"
|
||||
PoissonLaw = "Poisson distribution"
|
||||
ChiSquaredLaw = "Chi-squared distribution"
|
||||
StudentLaw = "Student's distribution"
|
||||
ChooseParameters = "Choose parameters"
|
||||
RepetitionNumber = "n: Number of trials"
|
||||
SuccessProbability = "p: Success probability"
|
||||
|
||||
@@ -6,12 +6,14 @@ Uniforme = "Uniforme"
|
||||
Normal = "Normal"
|
||||
Poisson = "Poisson"
|
||||
ChiSquared = "Chi-cuadrado"
|
||||
Student = "Student"
|
||||
BinomialLaw = "Distribución binomial"
|
||||
UniformLaw = "Distribución uniforme"
|
||||
ExponentialLaw = "Distribución exponencial"
|
||||
NormalLaw = "Distribución normal"
|
||||
PoissonLaw = "Distribución de Poisson"
|
||||
ChiSquaredLaw = "Distribución chi-cuadrado"
|
||||
StudentLaw = "Distribución de Student"
|
||||
ChooseParameters = "Seleccionar parámetros"
|
||||
RepetitionNumber = "n : Número de ensayos "
|
||||
SuccessProbability = "p : Probabilidad de éxito "
|
||||
|
||||
@@ -6,12 +6,14 @@ Uniforme = "Uniforme"
|
||||
Normal = "Normale"
|
||||
Poisson = "Poisson"
|
||||
ChiSquared = "Chi2"
|
||||
Student = "Student"
|
||||
BinomialLaw = "Loi binomiale"
|
||||
UniformLaw = "Loi uniforme"
|
||||
ExponentialLaw = "Loi exponentielle"
|
||||
NormalLaw = "Loi normale"
|
||||
PoissonLaw = "Loi de Poisson"
|
||||
ChiSquaredLaw = "Loi du chi2"
|
||||
StudentLaw = "Loi de Student"
|
||||
ChooseParameters = "Choisir les paramètres"
|
||||
RepetitionNumber = "n : Nombre de répétitions"
|
||||
SuccessProbability = "p : Probabilité de succès"
|
||||
|
||||
@@ -6,12 +6,14 @@ Uniforme = "Uniforme"
|
||||
Normal = "Normal"
|
||||
Poisson = "Poisson"
|
||||
ChiSquared = "Qui-quadrado"
|
||||
Student = "Student"
|
||||
BinomialLaw = "Distribuição binomial"
|
||||
UniformLaw = "Distribuição uniforme"
|
||||
ExponentialLaw = "Distribuição exponencial"
|
||||
NormalLaw = "Distribuição normal"
|
||||
PoissonLaw = "Distribuição de Poisson"
|
||||
ChiSquaredLaw = "Distribuição qui-quadrado"
|
||||
StudentLaw = "Distribuição de Student"
|
||||
ChooseParameters = "Selecionar os parâmetros"
|
||||
RepetitionNumber = "n : Número de ensaios"
|
||||
SuccessProbability = "p : Probabilidade de sucesso"
|
||||
|
||||
@@ -17,7 +17,8 @@ public:
|
||||
Exponential,
|
||||
Normal,
|
||||
Poisson,
|
||||
ChiSquared
|
||||
ChiSquared,
|
||||
Student
|
||||
};
|
||||
virtual ~Law() = default;
|
||||
virtual I18n::Message title() = 0;
|
||||
|
||||
50
apps/probability/law/student_law.cpp
Normal file
50
apps/probability/law/student_law.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "student_law.h"
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
float StudentLaw::xMin() const {
|
||||
return -xMax();
|
||||
}
|
||||
|
||||
float StudentLaw::xMax() const {
|
||||
return 5.0f;
|
||||
}
|
||||
|
||||
float StudentLaw::yMax() const {
|
||||
return coefficient() * (1.0f + k_displayTopMarginRatio);
|
||||
}
|
||||
|
||||
float StudentLaw::evaluateAtAbscissa(float x) const {
|
||||
const float d = m_parameter1;
|
||||
return coefficient() * std::pow(1+std::pow(x,2)/d, -(d+1)/2);
|
||||
}
|
||||
|
||||
bool StudentLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
return x >= FLT_EPSILON;
|
||||
}
|
||||
|
||||
double StudentLaw::cumulativeDistributiveFunctionAtAbscissa(double x) const {
|
||||
return 0;
|
||||
//TODO
|
||||
}
|
||||
|
||||
double StudentLaw::cumulativeDistributiveInverseForProbability(double * probability) {
|
||||
if (*probability >= 1.0) {
|
||||
return INFINITY;
|
||||
}
|
||||
if (*probability <= 0.0) {
|
||||
return -INFINITY;
|
||||
}
|
||||
return 0;
|
||||
//TODO
|
||||
}
|
||||
|
||||
float StudentLaw::coefficient() const {
|
||||
const float d = m_parameter1;
|
||||
const float lnOfResult = std::lgamma((d+1)/2) - std::lgamma(d/2) - (M_PI+d)/2;
|
||||
return std::exp(lnOfResult);
|
||||
}
|
||||
|
||||
}
|
||||
35
apps/probability/law/student_law.h
Normal file
35
apps/probability/law/student_law.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef PROBABILITY_STUDENT_LAW_H
|
||||
#define PROBABILITY_STUDENT_LAW_H
|
||||
|
||||
#include "one_parameter_law.h"
|
||||
|
||||
namespace Probability {
|
||||
|
||||
class StudentLaw : public OneParameterLaw {
|
||||
public:
|
||||
StudentLaw() : OneParameterLaw(4.0f) {}
|
||||
I18n::Message title() override { return I18n::Message::StudentLaw; }
|
||||
Type type() const override { return Type::Student; }
|
||||
bool isContinuous() const override { return true; }
|
||||
float xMin() const override;
|
||||
float xMax() const override;
|
||||
float yMax() const override;
|
||||
I18n::Message parameterNameAtIndex(int index) override {
|
||||
assert(index == 0);
|
||||
return I18n::Message::D;
|
||||
}
|
||||
I18n::Message parameterDefinitionAtIndex(int index) override {
|
||||
assert(index == 0);
|
||||
return I18n::Message::DegreesOfFreedomDefinition;
|
||||
}
|
||||
float evaluateAtAbscissa(float x) const override;
|
||||
bool authorizedValueAtIndex(float x, int index) const override;
|
||||
double cumulativeDistributiveFunctionAtAbscissa(double x) const override;
|
||||
double cumulativeDistributiveInverseForProbability(double * probability) override;
|
||||
private:
|
||||
float coefficient() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user