summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller/histogram.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/rpi/controller/histogram.cpp')
-rw-r--r--src/ipa/rpi/controller/histogram.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ipa/rpi/controller/histogram.cpp b/src/ipa/rpi/controller/histogram.cpp
index 16a9207f..0a27ba2c 100644
--- a/src/ipa/rpi/controller/histogram.cpp
+++ b/src/ipa/rpi/controller/histogram.cpp
@@ -45,20 +45,26 @@ double Histogram::quantile(double q, int first, int last) const
return first + frac;
}
-double Histogram::interQuantileMean(double qLo, double qHi) const
+double Histogram::interBinMean(double binLo, double binHi) const
{
- assert(qHi > qLo);
- double pLo = quantile(qLo);
- double pHi = quantile(qHi, (int)pLo);
+ assert(binHi > binLo);
double sumBinFreq = 0, cumulFreq = 0;
- for (double pNext = floor(pLo) + 1.0; pNext <= ceil(pHi);
- pLo = pNext, pNext += 1.0) {
- int bin = floor(pLo);
+ for (double binNext = floor(binLo) + 1.0; binNext <= ceil(binHi);
+ binLo = binNext, binNext += 1.0) {
+ int bin = floor(binLo);
double freq = (cumulative_[bin + 1] - cumulative_[bin]) *
- (std::min(pNext, pHi) - pLo);
+ (std::min(binNext, binHi) - binLo);
sumBinFreq += bin * freq;
cumulFreq += freq;
}
/* add 0.5 to give an average for bin mid-points */
return sumBinFreq / cumulFreq + 0.5;
}
+
+double Histogram::interQuantileMean(double qLo, double qHi) const
+{
+ assert(qHi > qLo);
+ double pLo = quantile(qLo);
+ double pHi = quantile(qHi, (int)pLo);
+ return interBinMean(pLo, pHi);
+}