aboutsummaryrefslogtreecommitdiffstats
path: root/stats/statsvariables.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-10 23:11:50 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 14:45:12 -0800
commitbbdd34d06927b57ef955eeec8578e2d85957002b (patch)
tree7721fb01e8fef2dca85b7aaa28e452808f37a76c /stats/statsvariables.cpp
parent1808804babb7d7f00e798236df16bbef58114a38 (diff)
downloadsubsurface-bbdd34d06927b57ef955eeec8578e2d85957002b.tar.gz
statistics: add count to box and whisker plots
When calculating the quartiles, we need the count of dives anyway, which makes it trivial to export this value to the frontend. Fixes an erroneous "mean", which should be "median". Suggested-by: Peter Zaal <peter.zaal@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/statsvariables.cpp')
-rw-r--r--stats/statsvariables.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/stats/statsvariables.cpp b/stats/statsvariables.cpp
index f9d75854b..628a63793 100644
--- a/stats/statsvariables.cpp
+++ b/stats/statsvariables.cpp
@@ -92,7 +92,7 @@ template<> QString invalid_value<QString>()
template<> StatsQuartiles invalid_value<StatsQuartiles>()
{
double NaN = std::numeric_limits<double>::quiet_NaN();
- return { NaN, NaN, NaN, NaN, NaN };
+ return { NaN, NaN, NaN, NaN, NaN, 0 };
}
static bool is_invalid_value(int i)
@@ -411,20 +411,20 @@ StatsQuartiles StatsVariable::quartiles(const std::vector<dive *> &dives) const
// This expects the value vector to be sorted!
StatsQuartiles StatsVariable::quartiles(const std::vector<StatsValue> &vec)
{
- size_t s = vec.size();
- if (s == 0)
+ int s = (int)vec.size();
+ if (s <= 0)
return invalid_value<StatsQuartiles>();
switch (s % 4) {
default:
// gcc doesn't recognize that we catch all possible values. disappointing.
case 0:
- return { vec[0].v, q3(&vec[s/4 - 1]), q2(&vec[s/2 - 1]), q1(&vec[s - s/4 - 1]), vec[s - 1].v };
+ return { vec[0].v, q3(&vec[s/4 - 1]), q2(&vec[s/2 - 1]), q1(&vec[s - s/4 - 1]), vec[s - 1].v, s };
case 1:
- return { vec[0].v, vec[s/4].v, vec[s/2].v, vec[s - s/4 - 1].v, vec[s - 1].v };
+ return { vec[0].v, vec[s/4].v, vec[s/2].v, vec[s - s/4 - 1].v, vec[s - 1].v, s };
case 2:
- return { vec[0].v, q1(&vec[s/4]), q2(&vec[s/2 - 1]), q3(&vec[s - s/4 - 2]), vec[s - 1].v };
+ return { vec[0].v, q1(&vec[s/4]), q2(&vec[s/2 - 1]), q3(&vec[s - s/4 - 2]), vec[s - 1].v, s };
case 3:
- return { vec[0].v, q2(&vec[s/4]), vec[s/2].v, q2(&vec[s - s/4 - 2]), vec[s - 1].v };
+ return { vec[0].v, q2(&vec[s/4]), vec[s/2].v, q2(&vec[s - s/4 - 2]), vec[s - 1].v, s };
}
}