diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/statistics.hh | 5 | ||||
-rw-r--r-- | src/base/stats/info.hh | 1 | ||||
-rw-r--r-- | src/base/stats/text.cc | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/base/statistics.hh b/src/base/statistics.hh index d98c79414..1f8a59326 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -1477,6 +1477,8 @@ class HistStor /** The current sum. */ Counter sum; + /** The sum of logarithm of each sample, used to compute geometric mean. */ + Counter logs; /** The sum of squares. */ Counter squares; /** The number of samples. */ @@ -1528,6 +1530,7 @@ class HistStor sum += val * number; squares += val * val * number; + logs += log(val) * number; samples += number; } @@ -1567,6 +1570,7 @@ class HistStor data.cvec[i] = cvec[i]; data.sum = sum; + data.logs = logs; data.squares = squares; data.samples = samples; } @@ -1589,6 +1593,7 @@ class HistStor sum = Counter(); squares = Counter(); samples = Counter(); + logs = Counter(); } }; diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh index 2c5b44a38..98e811747 100644 --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -183,6 +183,7 @@ struct DistData VCounter cvec; Counter sum; Counter squares; + Counter logs; Counter samples; }; diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 683ba7fe4..4cf98ca9e 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -367,6 +367,12 @@ DistPrint::operator()(ostream &stream) const print.value = data.samples ? data.sum / data.samples : NAN; print(stream); + if (data.type == Hist) { + print.name = base + "gmean"; + print.value = data.samples ? exp(data.logs / data.samples) : NAN; + print(stream); + } + Result stdev = NAN; if (data.samples) stdev = sqrt((data.samples * data.squares - data.sum * data.sum) / |