[apps/proba] Fix Student and Chi2 parameter name and initialisation

This commit is contained in:
Léa Saviot
2019-08-09 15:19:03 +02:00
parent 4ede2aa751
commit 9ddf8d4843
10 changed files with 19 additions and 18 deletions

View File

@@ -22,5 +22,5 @@ LambdaExponentialDefinition = "λ: Parameter"
MeanDefinition = "μ: Erwartungswert"
DeviationDefinition = "σ: Standardabweichung"
LambdaPoissonDefinition = "λ: Parameter"
DegreesOfFreedomDefinition = "d : Freiheitsgraden"
DegreesOfFreedomDefinition = "k: Anzahl der Freiheitsgrade"
ComputeProbability = "Wahrscheinlichkeit berechnen"

View File

@@ -22,5 +22,5 @@ LambdaExponentialDefinition = "λ: Rate parameter"
MeanDefinition = "μ: Mean"
DeviationDefinition = "σ: Standard deviation"
LambdaPoissonDefinition = "λ: Parameter"
DegreesOfFreedomDefinition = "d : Degrees of freedom"
DegreesOfFreedomDefinition = "k: Degrees of freedom"
ComputeProbability = "Calculate probabilities"

View File

@@ -22,5 +22,5 @@ LambdaExponentialDefinition = "λ : Parámetro"
MeanDefinition = "μ : Media"
DeviationDefinition = "σ : Desviación típica"
LambdaPoissonDefinition = "λ : Parámetro"
DegreesOfFreedomDefinition = "d : Grados de libertad"
DegreesOfFreedomDefinition = "k : Grados de libertad"
ComputeProbability = "Calcular las probabilidades"

View File

@@ -22,5 +22,5 @@ LambdaExponentialDefinition = "λ : Paramètre"
MeanDefinition = "μ : Espérance ou moyenne"
DeviationDefinition = "σ : Écart type"
LambdaPoissonDefinition = "λ : Paramètre"
DegreesOfFreedomDefinition = "d : Degrés de liberté"
DegreesOfFreedomDefinition = "k : Degrés de liberté"
ComputeProbability = "Calculer les probabilités"

View File

@@ -22,5 +22,5 @@ LambdaExponentialDefinition = "λ : Parâmetro"
MeanDefinition = "μ : Média"
DeviationDefinition = "σ : Desvio padrão"
LambdaPoissonDefinition = "λ : Parâmetro"
DegreesOfFreedomDefinition = "d : Graus de liberdade"
DegreesOfFreedomDefinition = "k : Graus de liberdade"
ComputeProbability = "Calcular probabilidades"

View File

@@ -14,12 +14,12 @@ float ChiSquaredLaw::xMax() const {
}
float ChiSquaredLaw::yMax() const {
const float halfD = m_parameter1/2;
const float halfk = m_parameter1/2;
float result;
if (halfD <= 1 + FLT_EPSILON) {
if (halfk <= 1 + FLT_EPSILON) {
result = 0.5f;
} else {
result = coefficient() * std::pow(halfD - 1, halfD - 1);
result = coefficient() * std::pow(halfk - 1, halfk - 1);
}
return result * (1.0f + k_displayTopMarginRatio);
}
@@ -28,9 +28,9 @@ float ChiSquaredLaw::evaluateAtAbscissa(float x) const {
if (x < 0) {
return NAN;
}
const float halfD = m_parameter1/2;
const float halfk = m_parameter1/2;
const float halfX = x/2;
return coefficient() * std::pow(halfX, halfD-1) * std::exp(-halfX);
return coefficient() * std::pow(halfX, halfk-1) * std::exp(-halfX);
}
bool ChiSquaredLaw::authorizedValueAtIndex(float x, int index) const {
@@ -57,8 +57,8 @@ double ChiSquaredLaw::cumulativeDistributiveInverseForProbability(double * proba
}
float ChiSquaredLaw::coefficient() const {
const float halfD = m_parameter1/2;
return 1 / (2 * std::exp(std::lgamma(halfD)));
const float halfk = m_parameter1/2;
return 1 / (2 * std::exp(std::lgamma(halfk)));
}
}

View File

@@ -7,7 +7,7 @@ namespace Probability {
class ChiSquaredLaw : public OneParameterLaw {
public:
ChiSquaredLaw() : OneParameterLaw(4.0f) {}
ChiSquaredLaw() : OneParameterLaw(1.0f) {}
I18n::Message title() override { return I18n::Message::ChiSquaredLaw; }
Type type() const override { return Type::ChiSquared; }
bool isContinuous() const override { return true; }
@@ -16,7 +16,7 @@ public:
float yMax() const override;
I18n::Message parameterNameAtIndex(int index) override {
assert(index == 0);
return I18n::Message::D;
return I18n::Message::K;
}
I18n::Message parameterDefinitionAtIndex(int index) override {
assert(index == 0);

View File

@@ -42,8 +42,8 @@ double StudentLaw::cumulativeDistributiveInverseForProbability(double * probabil
}
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;
const float k = m_parameter1;
const float lnOfResult = std::lgamma((k+1)/2) - std::lgamma(k/2) - (M_PI+k)/2;
return std::exp(lnOfResult);
}

View File

@@ -7,7 +7,7 @@ namespace Probability {
class StudentLaw : public OneParameterLaw {
public:
StudentLaw() : OneParameterLaw(4.0f) {}
StudentLaw() : OneParameterLaw(1.0f) {}
I18n::Message title() override { return I18n::Message::StudentLaw; }
Type type() const override { return Type::Student; }
bool isContinuous() const override { return true; }
@@ -16,7 +16,7 @@ public:
float yMax() const override;
I18n::Message parameterNameAtIndex(int index) override {
assert(index == 0);
return I18n::Message::D;
return I18n::Message::K;
}
I18n::Message parameterDefinitionAtIndex(int index) override {
assert(index == 0);

View File

@@ -34,6 +34,7 @@ IntCommand = "int(\x11,x,\x11,\x11)"
IntCommandWithArg = "int(f(x),x,a,b)"
InverseCommandWithArg = "inverse(M)"
InvSortCommandWithArg = "sort>(L)"
K = "k"
Lambda = "λ"
LcmCommandWithArg = "lcm(p,q)"
LinearRegressionFormula = " y=a·x+b "