mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Add a row in statistics calculation
Change-Id: I930abde428850a0b7a76e3f77ef961ee195da042
This commit is contained in:
committed by
EmilieNumworks
parent
357d76515b
commit
d7abc80097
@@ -25,7 +25,14 @@ constexpr static char deviationSpanishDefinition[] = {Ion::Charset::SmallSigma,
|
||||
constexpr static char deviationGermanDefinition[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'S', 't', 'a', 'n', 'd', 'a', 'r', 'd', 'a', 'b', 'w', 'e', 'i', 'c', 'h', 'u', 'n', 'g', 0};
|
||||
constexpr static char deviationPortugueseDefinition[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'D', 'e','s','v','i','o',' ','p','a','d','r','a','o', 0};
|
||||
|
||||
const char * messages[240][5] {
|
||||
constexpr static char frenchStandardDeviationSigma[] = {'E', 'c', 'a', 'r', 't', '-', 't', 'y', 'p', 'e', ' ', Ion::Charset::SmallSigma, 0};
|
||||
constexpr static char englishStandardDeviationSigma[] = {'S', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ','d','e', 'v', 'i', 'a', 't','i','o','n', ' ', Ion::Charset::SmallSigma, 0};
|
||||
constexpr static char spanishStandardDeviationSigma[] = {'D', 'e','s','v','i','a','c','i','o','n',' ','t','i','p','i','c','a', ' ', Ion::Charset::SmallSigma, 0};
|
||||
constexpr static char germanStandardDeviationSigma[] = {'S', 't', 'a', 'n', 'd', 'a', 'r', 'd', 'a', 'b', 'w', 'e', 'i', 'c', 'h', 'u', 'n', 'g', ' ', Ion::Charset::SmallSigma, 0};
|
||||
constexpr static char portugueseStandardDeviationSigma[] = {'D', 'e','s','v','i','o',' ','p','a','d','r','a','o', ' ', Ion::Charset::SmallSigma, 0};
|
||||
|
||||
|
||||
const char * messages[242][5] {
|
||||
{"Warning", "Attention", "Cuidado", "Achtung", "Atencao"},
|
||||
{"Confirm", "Valider", "Confirmar", "Bestatigen", "Confirmar"},
|
||||
{"Cancel", "Annuler", "Cancelar", "Abbrechen", "Cancelar"},
|
||||
@@ -209,6 +216,8 @@ const char * messages[240][5] {
|
||||
{"Range", "Etendue", "Rango", "Spannweite", "Amplitude"},
|
||||
{"Mean", "Moyenne", "Media", "Mittelwert", "Media"},
|
||||
{"Standard deviation", "Ecart type", "Desviacion tipica", "Standardabweichung", "Desvio padrao"},
|
||||
{englishStandardDeviationSigma, frenchStandardDeviationSigma, spanishStandardDeviationSigma, germanStandardDeviationSigma, portugueseStandardDeviationSigma},
|
||||
{"Sample std deviation s", "Ecart type echantillon s", "Desviacion tipica muestral s", "Standardabweichung s", "Desvio padrao amostral s"},
|
||||
{"Variance", "Variance", "Varianza", "Varianz", "Variancia"},
|
||||
{"Interquartile range", "Ecart interquartile", "Rango intercuartilo", "Interquartilsabstand", "Interquartil"},
|
||||
{"Sum of squares", "Somme des carres", "Suma cuadrados", "Quadratsumme", "Soma dos quadrados"},
|
||||
|
||||
@@ -178,6 +178,8 @@ namespace I18n {
|
||||
Range,
|
||||
Mean,
|
||||
StandardDeviation,
|
||||
StandardDeviationSigma,
|
||||
SampleStandardDeviationS,
|
||||
Deviation,
|
||||
InterquartileRange,
|
||||
SquareSum,
|
||||
|
||||
@@ -74,13 +74,13 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
myCell->setEven(j%2 == 0);
|
||||
myCell->setHighlighted(i == selectedColumn() && j == selectedRow());
|
||||
if (i == 0) {
|
||||
I18n::Message titles[k_totalNumberOfRows] = {I18n::Message::TotalSize, I18n::Message::Minimum, I18n::Message::Maximum, I18n::Message::Range, I18n::Message::Mean, I18n::Message::StandardDeviation, I18n::Message::Deviation, I18n::Message::FirstQuartile, I18n::Message::ThirdQuartile, I18n::Message::Median, I18n::Message::InterquartileRange, I18n::Message::Sum, I18n::Message::SquareSum};
|
||||
I18n::Message titles[k_totalNumberOfRows] = {I18n::Message::TotalSize, I18n::Message::Minimum, I18n::Message::Maximum, I18n::Message::Range, I18n::Message::Mean, I18n::Message::StandardDeviationSigma, I18n::Message::Deviation, I18n::Message::FirstQuartile, I18n::Message::ThirdQuartile, I18n::Message::Median, I18n::Message::InterquartileRange, I18n::Message::Sum, I18n::Message::SquareSum, I18n::Message::SampleStandardDeviationS};
|
||||
EvenOddMessageTextCell * myCell = (EvenOddMessageTextCell *)cell;
|
||||
myCell->setMessage(titles[j]);
|
||||
} else {
|
||||
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::thirdQuartile, &Store::median, &Store::quartileRange, &Store::sum, &Store::squaredValueSum, &Store::sampleStandardDeviation};
|
||||
double calculation = (m_store->*calculationMethods[j])();
|
||||
EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell;
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
@@ -90,13 +90,41 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::columnWidth(int i) {
|
||||
return k_cellWidth;
|
||||
if (i == 0) {
|
||||
return k_titleCellWidth;
|
||||
}
|
||||
return Ion::Display::Width - Metric::CommonRightMargin - Metric::CommonLeftMargin-k_titleCellWidth;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::rowHeight(int j) {
|
||||
return k_cellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedWidthFromIndex(int i) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < i; k++) {
|
||||
result += columnWidth(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedHeightFromIndex(int j) {
|
||||
return j*rowHeight(0);
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
while (result < offsetX && i < numberOfRows()) {
|
||||
result += rowHeight(i++);
|
||||
}
|
||||
return (result < offsetX || offsetX == 0) ? i : i - 1;
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
return (offsetY-1) / rowHeight(0);
|
||||
}
|
||||
|
||||
HighlightCell * CalculationController::reusableCell(int index, int type) {
|
||||
assert(index < k_totalNumberOfRows);
|
||||
if (type == 0) {
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include <escher.h>
|
||||
#include "store.h"
|
||||
#include "../shared/tab_table_controller.h"
|
||||
#include "../shared/regular_table_view_data_source.h"
|
||||
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
class CalculationController : public Shared::TabTableController, public Shared::RegularTableViewDataSource, public ButtonRowDelegate, public AlternateEmptyViewDelegate {
|
||||
class CalculationController : public Shared::TabTableController, public ButtonRowDelegate, public TableViewDataSource, public AlternateEmptyViewDelegate {
|
||||
|
||||
public:
|
||||
CalculationController(Responder * parentResponder, ButtonRowController * header, Store * store);
|
||||
@@ -26,6 +24,10 @@ public:
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
|
||||
KDCoordinate columnWidth(int i) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
KDCoordinate cumulatedWidthFromIndex(int i) override;
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
@@ -33,10 +35,10 @@ private:
|
||||
Responder * tabController() const override;
|
||||
View * loadView() override;
|
||||
void unloadView(View * view) override;
|
||||
constexpr static int k_totalNumberOfRows = 13;
|
||||
constexpr static int k_totalNumberOfRows = 14;
|
||||
constexpr static int k_maxNumberOfDisplayableRows = 11;
|
||||
static constexpr KDCoordinate k_cellHeight = 20;
|
||||
static constexpr KDCoordinate k_cellWidth = Ion::Display::Width/2 - Metric::CommonRightMargin/2 - Metric::CommonLeftMargin/2;
|
||||
static constexpr KDCoordinate k_titleCellWidth = 175;
|
||||
EvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows];
|
||||
EvenOddBufferTextCell * m_calculationCells[k_maxNumberOfDisplayableRows];
|
||||
Store * m_store;
|
||||
|
||||
@@ -132,6 +132,12 @@ double Store::standardDeviation() {
|
||||
return std::sqrt(variance());
|
||||
}
|
||||
|
||||
double Store::sampleStandardDeviation() {
|
||||
double n = sumOfColumn(1);
|
||||
double s = std::sqrt(n/(n-1.0));
|
||||
return s*standardDeviation();
|
||||
}
|
||||
|
||||
double Store::firstQuartile() {
|
||||
int firstQuartileIndex = std::ceil(sumOfColumn(1)/4);
|
||||
return sortedElementNumber(firstQuartileIndex);
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
double mean();
|
||||
double variance();
|
||||
double standardDeviation();
|
||||
double sampleStandardDeviation();
|
||||
double firstQuartile();
|
||||
double thirdQuartile();
|
||||
double quartileRange();
|
||||
|
||||
Reference in New Issue
Block a user