summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2010-05-12 08:31:39 +0200
committerjasplin <qt-info@nokia.com>2010-05-12 08:31:39 +0200
commit417f2f91bb7dd10dff951f7f1bc3d6e25d85fed2 (patch)
tree4e0be21e2092c10dfcea4e8f7133fb6088ee59e5
parent7acbe7afc40eabd9a88d500abb377b1e320cc1b4 (diff)
Apply certain instability tests within from..to time range only.
To determine whether a result history is unstable for the ASF stats, the tests for zero values and max-min difference are now applied only to results that are within the from..to time range.
-rw-r--r--src/bm/asfstats.cpp4
-rw-r--r--src/bm/resulthistoryinfo.cpp27
-rw-r--r--src/bm/resulthistoryinfo.h7
3 files changed, 25 insertions, 13 deletions
diff --git a/src/bm/asfstats.cpp b/src/bm/asfstats.cpp
index 4074a77..105b424 100644
--- a/src/bm/asfstats.cpp
+++ b/src/bm/asfstats.cpp
@@ -152,8 +152,8 @@ void ASFStats::compute(const QList<ResultHistoryInfo *> &rhInfos, StatsInfo *sta
// Compute stability stats for raw (unsmoothed) data ...
rhInfos.at(i)->computeStabilityStats(
- diffTolerance, stabTolerance, &zerosFound, &total, &stable, &uniqueLevels, &minLevel,
- &maxLevel);
+ diffTolerance, stabTolerance, fromTimestamp, toTimestamp, &zerosFound, &total,
+ &stable, &uniqueLevels, &minLevel, &maxLevel);
Q_ASSERT(total > 0);
const qreal sf = 100 * (stable / qreal(total));
diff --git a/src/bm/resulthistoryinfo.cpp b/src/bm/resulthistoryinfo.cpp
index 0e2d23b..c8bc2ca 100644
--- a/src/bm/resulthistoryinfo.cpp
+++ b/src/bm/resulthistoryinfo.cpp
@@ -134,16 +134,16 @@ bool ResultHistoryInfo::equal(int i, int j, int diffTolerance) const
// ### 2 B DOCUMENTED!
void ResultHistoryInfo::startSubsequence(
int pos, qreal diffTolerance, QMap<int, int> *uniqueLevels, qreal *minLevel,
- qreal *maxLevel, bool first) const
+ qreal *maxLevel, bool insideRange, bool firstInsideRange) const
{
Q_ASSERT(pos >= 0);
Q_ASSERT(pos < values.size());
const qreal v = values.at(pos);
- if (first) {
+ if (firstInsideRange) {
*minLevel = *maxLevel = v;
- } else {
+ } else if (insideRange) {
*minLevel = qMin(*minLevel, v);
*maxLevel = qMax(*maxLevel, v);
}
@@ -208,8 +208,8 @@ void ResultHistoryInfo::computeMaxESSStats(
// ### 2 B DOCUMENTED!
void ResultHistoryInfo::computeStabilityStats(
- qreal diffTolerance, int stabTolerance, bool *zerosFound, int *total, int *stable,
- int *uniqueLevels, qreal *minLevel, qreal *maxLevel) const
+ qreal diffTolerance, int stabTolerance, int fromTimestamp, int toTimestamp, bool *zerosFound,
+ int *total, int *stable, int *uniqueLevels, qreal *minLevel, qreal *maxLevel) const
{
*zerosFound = false;
*total = *stable = *uniqueLevels = 0;
@@ -220,21 +220,32 @@ void ResultHistoryInfo::computeStabilityStats(
int basePos = -1;
int seqSize = 0;
+ bool insideRangePrev = false;
+
for (int i = 0; i < values.size(); ++i) {
++seqSize;
- if ((!(*zerosFound)) && (values.at(i) == 0.0))
+ const int timestamp = timestamps_.at(i);
+ const bool insideRange = ((timestamp >= fromTimestamp) && (timestamp <= toTimestamp));
+ const bool firstInsideRange = insideRange && (!insideRangePrev);
+ insideRangePrev = insideRange;
+
+ if (insideRange && (!(*zerosFound)) && (values.at(i) == 0.0))
*zerosFound = true;
if (basePos == -1) {
basePos = i;
- startSubsequence(basePos, diffTolerance, &uniqueLevels_, minLevel, maxLevel, true);
+ startSubsequence(
+ basePos, diffTolerance, &uniqueLevels_, minLevel, maxLevel, insideRange,
+ firstInsideRange);
} else if (!equal(basePos, i, diffTolerance)) {
endSubsequence(seqSize, total, stable, stabTolerance);
seqSize = 1;
basePos = i;
- startSubsequence(basePos, diffTolerance, &uniqueLevels_, minLevel, maxLevel);
+ startSubsequence(
+ basePos, diffTolerance, &uniqueLevels_, minLevel, maxLevel, insideRange,
+ firstInsideRange);
}
if (i == values.size() - 1)
diff --git a/src/bm/resulthistoryinfo.h b/src/bm/resulthistoryinfo.h
index b5bdff0..e74fc49 100644
--- a/src/bm/resulthistoryinfo.h
+++ b/src/bm/resulthistoryinfo.h
@@ -72,8 +72,9 @@ public:
void computeMaxESSStats(qreal diffTolerance, int stabTolerance, int *total, int *stable) const;
void computeStabilityStats(
- qreal diffTolerance, int stabTolerance, bool *zerosFound, int *total, int *stable,
- int *uniqueLevels, qreal *minLevel, qreal *maxLevel) const;
+ qreal diffTolerance, int stabTolerance, int fromTimestamp, int toTimestamp,
+ bool *zerosFound, int *total, int *stable, int *uniqueLevels, qreal *minLevel,
+ qreal *maxLevel) const;
private:
int bmcontextId_;
@@ -102,7 +103,7 @@ private:
bool equal(int i, int j, int diffTolerance) const;
void startSubsequence(
int pos, qreal diffTolerance, QMap<int, int> *uniqueLevels, qreal *minLevel,
- qreal *maxLevel, bool first = false) const;
+ qreal *maxLevel, bool insideRange, bool firstInsideRange = false) const;
static void endSubsequence(int seqSize, int *total, int *stable, int stabTolerance);
};