mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[statistics] Added 3 new measurements
This commit is contained in:
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Standardabweichung s"
|
||||
SumValues = "Summe"
|
||||
SumSquareValues = "Quadratsumme"
|
||||
InterquartileRange = "Interquartilsabstand"
|
||||
GeometricMean = "Geometrisches Mittel"
|
||||
HarmonicMean = "Harmonische Mittel"
|
||||
StatisticsMode = "Modus "
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Sample std deviation s"
|
||||
SumValues = "Sum of values"
|
||||
SumSquareValues = "Sum of squared values"
|
||||
InterquartileRange = "Interquartile range"
|
||||
GeometricMean = "Geometric mean"
|
||||
HarmonicMean = "Harmonic Mean"
|
||||
StatisticsMode = "Mode"
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Desviación típica s"
|
||||
SumValues = "Suma"
|
||||
SumSquareValues = "Suma cuadrados"
|
||||
InterquartileRange = "Rango intercuartilo"
|
||||
GeometricMean = "Significado geometrico"
|
||||
HarmonicMean = "Significado armonico"
|
||||
StatisticsMode = "Modo"
|
||||
|
||||
@@ -16,6 +16,9 @@ RectangleWidth = "Largeur des rectangles"
|
||||
BarStart = "Début de la série"
|
||||
FirstQuartile = "Premier quartile"
|
||||
Median = "Médiane"
|
||||
GeometricMean = "Moyenne géométrique"
|
||||
HarmonicMean = "Moyenne harmonique"
|
||||
StatisticsMode = "Mode"
|
||||
ThirdQuartile = "Troisième quartile"
|
||||
TotalFrequency = "Effectif total"
|
||||
Range = "Étendue"
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Minta std eltérés σ"
|
||||
SumValues = "Értékek összege"
|
||||
SumSquareValues = "Négyzetértékek összege"
|
||||
InterquartileRange = "Interkvartilis tartomány"
|
||||
GeometricMean = "Geometriai átlag"
|
||||
HarmonicMean = "Harmonikus átlag"
|
||||
StatisticsMode = "Mód"
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Dev. std campionaria s"
|
||||
SumValues = "Somma"
|
||||
SumSquareValues = "Somma dei quadrati"
|
||||
InterquartileRange = "Scarto interquartile"
|
||||
GeometricMean = "Media geometrica"
|
||||
HarmonicMean = "Media armonica"
|
||||
StatisticsMode = "Modalità"
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Standaardafwijking s"
|
||||
SumValues = "Som"
|
||||
SumSquareValues = "Som van kwadraten"
|
||||
InterquartileRange = "Interkwartielafstand"
|
||||
GeometricMean = "Geometrisch gemiddelde"
|
||||
HarmonicMean = "Harmonisch gemiddelde"
|
||||
StatisticsMode = "Modus"
|
||||
|
||||
@@ -24,3 +24,6 @@ SampleStandardDeviationS = "Desvio padrão amostral s"
|
||||
SumValues = "Somatório"
|
||||
SumSquareValues = "Soma dos quadrados"
|
||||
InterquartileRange = "Amplitude interquartil"
|
||||
GeometricMean = "Média geométrica"
|
||||
HarmonicMean = "Média Harmônica"
|
||||
StatisticsMode = "Modo"
|
||||
|
||||
@@ -79,12 +79,15 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
I18n::Message::Maximum,
|
||||
I18n::Message::Range,
|
||||
I18n::Message::Mean,
|
||||
I18n::Message::GeometricMean,
|
||||
I18n::Message::HarmonicMean,
|
||||
I18n::Message::StandardDeviationSigma,
|
||||
I18n::Message::Deviation,
|
||||
I18n::Message::FirstQuartile,
|
||||
I18n::Message::ThirdQuartile,
|
||||
I18n::Message::Median,
|
||||
I18n::Message::InterquartileRange,
|
||||
I18n::Message::StatisticsMode,
|
||||
I18n::Message::SumValues,
|
||||
I18n::Message::SumSquareValues,
|
||||
I18n::Message::SampleStandardDeviationS};
|
||||
@@ -94,8 +97,8 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
}
|
||||
// Display a calculation cell
|
||||
CalculPointer calculationMethods[k_totalNumberOfRows] = {&Store::sumOfOccurrences, &Store::minValue,
|
||||
&Store::maxValue, &Store::range, &Store::mean, &Store::standardDeviation, &Store::variance, &Store::firstQuartile,
|
||||
&Store::thirdQuartile, &Store::median, &Store::quartileRange, &Store::sum, &Store::squaredValueSum, &Store::sampleStandardDeviation};
|
||||
&Store::maxValue, &Store::range, &Store::mean, &Store::geometricMean, &Store::harmonicMean, &Store::standardDeviation, &Store::variance, &Store::firstQuartile,
|
||||
&Store::thirdQuartile, &Store::median, &Store::quartileRange, &Store::mode, &Store::sum, &Store::squaredValueSum, &Store::sampleStandardDeviation};
|
||||
int seriesIndex = m_store->indexOfKthNonEmptySeries(i-1);
|
||||
double calculation = (m_store->*calculationMethods[j-1])(seriesIndex);
|
||||
EvenOddBufferTextCell * calculationCell = static_cast<EvenOddBufferTextCell *>(cell);
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
private:
|
||||
static constexpr int k_totalNumberOfRows = 15;
|
||||
static constexpr int k_totalNumberOfRows = 18;
|
||||
static constexpr int k_maxNumberOfDisplayableRows = 11;
|
||||
static constexpr int k_numberOfCalculationCells = 3 * k_maxNumberOfDisplayableRows;
|
||||
static constexpr int k_numberOfSeriesTitleCells = 3;
|
||||
|
||||
@@ -162,6 +162,34 @@ double Store::mean(int series) const {
|
||||
return sum(series)/sumOfOccurrences(series);
|
||||
}
|
||||
|
||||
double Store::geometricMean(int series) const {
|
||||
double geometricMean = 1;
|
||||
int numberOfCoefficients = 0;
|
||||
int numberOfPairs = numberOfPairsOfSeries(series);
|
||||
for (int k = 0; k < numberOfPairs; k++) {
|
||||
if (m_data[series][0][k] <= 0) {
|
||||
return NAN;
|
||||
}
|
||||
geometricMean *= std::pow(m_data[series][0][k], m_data[series][1][k]);
|
||||
numberOfCoefficients += m_data[series][1][k];
|
||||
}
|
||||
return std::pow(geometricMean, 1.0/numberOfCoefficients);
|
||||
}
|
||||
|
||||
double Store::harmonicMean(int series) const {
|
||||
double harmonicMean = 0;
|
||||
int numberOfCoefficients = 0;
|
||||
int numberOfPairs = numberOfPairsOfSeries(series);
|
||||
for (int k = 0; k < numberOfPairs; k++) {
|
||||
if (m_data[series][0][k] <= 0) {
|
||||
return NAN;
|
||||
}
|
||||
harmonicMean += m_data[series][1][k]/m_data[series][0][k];
|
||||
numberOfCoefficients += m_data[series][1][k];
|
||||
}
|
||||
return numberOfCoefficients/harmonicMean;
|
||||
}
|
||||
|
||||
double Store::variance(int series) const {
|
||||
/* We use the Var(X) = E[(X-E[X])^2] definition instead of Var(X) = E[X^2] - E[X]^2
|
||||
* to ensure a positive result and to minimize rounding errors */
|
||||
@@ -217,6 +245,22 @@ double Store::quartileRange(int series) const {
|
||||
return thirdQuartile(series)-firstQuartile(series);
|
||||
}
|
||||
|
||||
double Store::mode(int series) const {
|
||||
double modeValue = NAN;
|
||||
double numberOfRepeats = 0;
|
||||
int numberOfPairs = numberOfPairsOfSeries(series);
|
||||
for (int k = 0; k < numberOfPairs; k++) {
|
||||
if (m_data[series][1][k] > numberOfRepeats) {
|
||||
modeValue = m_data[series][0][k];
|
||||
numberOfRepeats = m_data[series][1][k];
|
||||
}
|
||||
else if (m_data[series][1][k] == numberOfRepeats) {
|
||||
modeValue = NAN;
|
||||
}
|
||||
}
|
||||
return modeValue;
|
||||
}
|
||||
|
||||
double Store::median(int series) const {
|
||||
return sortedElementAtCumulatedFrequency(series, 1.0/2.0, true);
|
||||
}
|
||||
|
||||
@@ -35,12 +35,15 @@ public:
|
||||
double minValue(int series) const;
|
||||
double range(int series) const;
|
||||
double mean(int series) const;
|
||||
double geometricMean(int series) const;
|
||||
double harmonicMean(int series) const;
|
||||
double variance(int series) const;
|
||||
double standardDeviation(int series) const;
|
||||
double sampleStandardDeviation(int series) const;
|
||||
double firstQuartile(int series) const;
|
||||
double thirdQuartile(int series) const;
|
||||
double quartileRange(int series) const;
|
||||
double mode(int series) const;
|
||||
double median(int series) const;
|
||||
double sum(int series) const;
|
||||
double squaredValueSum(int series) const;
|
||||
|
||||
Reference in New Issue
Block a user