[issue35606] Add prod() function to the math module

STINNER Victor report at bugs.python.org
Fri Jan 4 17:03:45 EST 2019


STINNER Victor <vstinner at redhat.com> added the comment:

Computing the geometric mean of numbers require to compute the product of these numbers:
https://en.wikipedia.org/wiki/Geometric_mean

The geometric mean can be used to summarize benchmark results using different units to get a single number.

--

When computing the product of floats, is there a smart implementation reducing the error? I'm asking because math.fsum() doesn't use a naive loop but a smart implementation to minimize the error.

--

Mark Dickinson:
> On this subject, some effort has been made in the past to make (almost) all the math module functions behave consistently with respect to things like exceptions, overflow, infinities, nans, signed zeros, etc.

"versus"

Rémi Lapeyre:
> A naive implementation would also support user-defined types which would probably be a good thing IMO

Would it make sense to only implement product for an iterable of floats, as math.fsum()?

----------
nosy: +vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35606>
_______________________________________


More information about the Python-bugs-list mailing list