@@ -43,7 +43,7 @@ or sample.
4343
4444======================= ===============================================================
4545:func: `mean ` Arithmetic mean ("average") of data.
46- :func: `fmean ` Fast, floating point arithmetic mean.
46+ :func: `fmean ` Fast, floating point arithmetic mean, with optional weighting .
4747:func: `geometric_mean ` Geometric mean of data.
4848:func: `harmonic_mean ` Harmonic mean of data.
4949:func: `median ` Median (middle value) of data.
@@ -128,7 +128,7 @@ However, for reading convenience, most of the examples show sorted sequences.
128128 ``mean(data) `` is equivalent to calculating the true population mean μ.
129129
130130
131- .. function :: fmean(data)
131+ .. function :: fmean(data, weights=None )
132132
133133 Convert *data * to floats and compute the arithmetic mean.
134134
@@ -141,8 +141,25 @@ However, for reading convenience, most of the examples show sorted sequences.
141141 >>> fmean([3.5 , 4.0 , 5.25 ])
142142 4.25
143143
144+ Optional weighting is supported. For example, a professor assigns a
145+ grade for a course by weighting quizzes at 20%, homework at 20%, a
146+ midterm exam at 30%, and a final exam at 30%:
147+
148+ .. doctest ::
149+
150+ >>> grades = [85 , 92 , 83 , 91 ]
151+ >>> weights = [0.20 , 0.20 , 0.30 , 0.30 ]
152+ >>> fmean(grades, weights)
153+ 87.6
154+
155+ If *weights * is supplied, it must be the same length as the *data * or
156+ a :exc: `ValueError ` will be raised.
157+
144158 .. versionadded :: 3.8
145159
160+ .. versionchanged :: 3.11
161+ Added support for *weights *.
162+
146163
147164.. function :: geometric_mean(data)
148165
0 commit comments