[New-bugs-announce] [issue26913] statistics.mean of bools
report at bugs.python.org
Mon May 2 16:59:11 EDT 2016
New submission from Peter Norvig:
mean([True, True, True, False]) should be 0.75, but it returns 0.25.
The fix is to change _sum so that when the type is bool, the result should be coerced to int, not bool.
Why it is important for statistics.mean to work with bools:
It is natural to say something like
mean(x > threshold for x in data)
and expect to get the percentage of items in data that are above threshold.
components: Library (Lib)
title: statistics.mean of bools
versions: Python 3.4, Python 3.5, Python 3.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce