[New-bugs-announce] [issue44150] Add optional weights parameter to statistics.fmean()

Raymond Hettinger report at bugs.python.org
Sun May 16 14:56:52 EDT 2021

New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

Weighted averages are another basic that we should support.

A professor assigns a grade for a course by weighting quizzes at 20%, homework at 20%, a midterm exam at 30%, and a final exam at 30%:

>>> grades = [85, 92, 83, 91]
>>> weights = [0.20, 0.20, 0.30, 0.30]
>>> fmean(grades, weights)

The API here matches that for harmonic_mean() and random.choices(), the other places where we support optional weights.

components: Library (Lib)
messages: 393751
nosy: rhettinger, steven.daprano
priority: normal
severity: normal
status: open
title: Add optional weights parameter to statistics.fmean()
type: enhancement
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list