Closed vstinner closed 3 years ago
My use case is to compute a geometric mean for pyperformance to avoid comparing N benchmark results manually, ignoring some benchmark with an absolute difference lower than N percent (ex: 5%).
compute the product and then the nth root
If we pick this approach, math.prod() added to Python 3.8 can be used.
So log+exp seems better to avoid overflow. See also https://bugs.python.org/issue41458 "Avoid overflow/underflow in math.prod()".
I wrote PR #79.
It's now implemented in the master branch: fiexd by PR #79.
There are two approaches to compute a geometric mean:
scipy uses log+exp: https://github.com/scipy/scipy/blob/bf3ea59982a552e65f0388d4dd17b256b962adbb/scipy/stats/stats.py#L349-L411
The geometric mean should help to compute N benchmarks with a single value.
For example, https://speed.pypy.org/ says "The geometric average of all benchmarks is 0.23 or 4.3 times faster than cpython."