diff options
author | jasplin <qt-info@nokia.com> | 2010-05-13 22:29:18 +0200 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2010-05-13 22:29:18 +0200 |
commit | 2fb17426b78f090af8583c5ca1bf62f72da0bef0 (patch) | |
tree | 42d188bb8d8332a99464e01b3944b3f64e3be07e | |
parent | c16188624690c8ea777d579c9800883289db0db2 (diff) |
Include 'from time' sample in 'inside range'.
The 'from' time sample (i.e. the last smooth result
not later than the 'from' time) is included in the
range in which the 'zero' and 'max level difference'
instability conditions apply.
This patch also avoids a potential division by zero
(that would occur if the max- and min levels were not
found).
-rw-r--r-- | src/bm/asfstats.cpp | 5 | ||||
-rw-r--r-- | src/bm/resulthistoryinfo.cpp | 13 | ||||
-rw-r--r-- | src/bm/resulthistoryinfo.h | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/bm/asfstats.cpp b/src/bm/asfstats.cpp index eb71006..d8e7b4b 100644 --- a/src/bm/asfstats.cpp +++ b/src/bm/asfstats.cpp @@ -149,17 +149,18 @@ void ASFStats::compute(const QList<ResultHistoryInfo *> &rhInfos, StatsInfo *sta int uniqueLevels = 0; qreal minLevel = 0; qreal maxLevel = 0; + bool maxMinFound = false; // Compute stability stats for raw (unsmoothed) data ... rhInfos.at(i)->computeStabilityStats( diffTolerance, stabTolerance, fromTimestamp, toTimestamp, &zerosFound, &total, - &stable, &uniqueLevels, &minLevel, &maxLevel); + &stable, &uniqueLevels, &minLevel, &maxLevel, &maxMinFound); Q_ASSERT(total > 0); const qreal sf = 100 * (stable / qreal(total)); const qreal lf = 100 * (uniqueLevels / qreal(total)); - const qreal maxLD = zerosFound ? -1 : (100 * ((maxLevel / minLevel) - 1)); + const qreal maxLD = maxMinFound ? (100 * ((maxLevel / minLevel) - 1)) : 0.0; int fromPos = -1; rhInfos.at(i)->findSmoothPos(fromTimestamp, &fromPos); diff --git a/src/bm/resulthistoryinfo.cpp b/src/bm/resulthistoryinfo.cpp index d5dd4e5..1b5d931 100644 --- a/src/bm/resulthistoryinfo.cpp +++ b/src/bm/resulthistoryinfo.cpp @@ -199,11 +199,13 @@ void ResultHistoryInfo::computeMaxESSStats( // ### 2 B DOCUMENTED! void ResultHistoryInfo::computeStabilityStats( qreal diffTolerance, int stabTolerance, int fromTimestamp, int toTimestamp, bool *zerosFound, - int *total, int *stable, int *uniqueLevels, qreal *minLevel, qreal *maxLevel) const + int *total, int *stable, int *uniqueLevels, qreal *minLevel, qreal *maxLevel, + bool *maxMinFound) const { *zerosFound = false; *total = *stable = *uniqueLevels = 0; - *minLevel = *maxLevel = 0; + *minLevel = *maxLevel = -1.0; + *maxMinFound = false; QMap<int, int> uniqueLevels_; // <pos, count> @@ -212,12 +214,16 @@ void ResultHistoryInfo::computeStabilityStats( bool insideRangePrev = false; + int smoothFromPos = -1; + findSmoothPos(fromTimestamp, &smoothFromPos); + for (int i = 0; i < values.size(); ++i) { ++seqSize; const int timestamp = timestamps_.at(i); - const bool insideRange = ((timestamp >= fromTimestamp) && (timestamp <= toTimestamp)); + const bool insideRange = (i == smoothFromPos) + || ((timestamp >= fromTimestamp) && (timestamp <= toTimestamp)); const bool firstInsideRange = insideRange && (!insideRangePrev); insideRangePrev = insideRange; @@ -227,6 +233,7 @@ void ResultHistoryInfo::computeStabilityStats( const qreal val = values.at(i); if (firstInsideRange) { *minLevel = *maxLevel = val; + *maxMinFound = true; } else if (insideRange) { *minLevel = qMin(*minLevel, val); *maxLevel = qMax(*maxLevel, val); diff --git a/src/bm/resulthistoryinfo.h b/src/bm/resulthistoryinfo.h index 21132b9..ff0f856 100644 --- a/src/bm/resulthistoryinfo.h +++ b/src/bm/resulthistoryinfo.h @@ -74,7 +74,7 @@ public: void computeStabilityStats( qreal diffTolerance, int stabTolerance, int fromTimestamp, int toTimestamp, bool *zerosFound, int *total, int *stable, int *uniqueLevels, qreal *minLevel, - qreal *maxLevel) const; + qreal *maxLevel, bool *maxMinFound) const; private: int bmcontextId_; |