mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/i18n] Derive preferences from country
Each country comes with an set of preferences, built at compile time by apps/i18n.py, used to define : - the exam mode - the method for computing quartiles - the unit system in which to output the results with units Functions to access those preferences are available in via sharedGlobalPreferences. Change-Id: I220ebaa9b9e8954dfe33cd51936f47505b98978d
This commit is contained in:
committed by
Émilie Feral
parent
e2a6edd78f
commit
2b59509fdd
@@ -1,6 +1,5 @@
|
||||
#include "store.h"
|
||||
#include <apps/global_preferences.h>
|
||||
#include <apps/i18n.h>
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <cmath>
|
||||
@@ -199,20 +198,18 @@ double Store::sampleStandardDeviation(int series) const {
|
||||
* the more general definition if non-integral frequencies are found.
|
||||
* */
|
||||
double Store::firstQuartile(int series) const {
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->country() == I18n::Country::FR
|
||||
|| GlobalPreferences::sharedGlobalPreferences()->country() == I18n::Country::IT
|
||||
|| !frequenciesAreInteger(series)) {
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->methodForQuartiles() == I18n::MethodForQuartiles::CumulatedFrequency || !frequenciesAreInteger(series)) {
|
||||
return sortedElementAtCumulatedFrequency(series, 1.0/4.0);
|
||||
}
|
||||
assert(GlobalPreferences::sharedGlobalPreferences()->methodForQuartiles() == I18n::MethodForQuartiles::MedianOfSublist);
|
||||
return sortedElementAtCumulatedPopulation(series, std::floor(sumOfOccurrences(series) / 2.) / 2., true);
|
||||
}
|
||||
|
||||
double Store::thirdQuartile(int series) const {
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->country() == I18n::Country::FR
|
||||
|| GlobalPreferences::sharedGlobalPreferences()->country() == I18n::Country::IT
|
||||
|| !frequenciesAreInteger(series)) {
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->methodForQuartiles() == I18n::MethodForQuartiles::CumulatedFrequency || !frequenciesAreInteger(series)) {
|
||||
return sortedElementAtCumulatedFrequency(series, 3.0/4.0);
|
||||
}
|
||||
assert(GlobalPreferences::sharedGlobalPreferences()->methodForQuartiles() == I18n::MethodForQuartiles::MedianOfSublist);
|
||||
return sortedElementAtCumulatedPopulation(series, std::ceil(3./2. * sumOfOccurrences(series)) / 2., true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user