listtools.arithmetic_mean

abjad.tools.listtools.arithmetic_mean(l)

New in version 1.1.1.

Return the arithmetic mean of the elements in iterable l.

Where possible return an exact integer.

abjad> l = [1, 2, 2, 20, 30]
abjad> listtools.arithmetic_mean(l)
11

Otherwise return a rational.

abjad> l = [1, 2, 20]
abjad> listtools.arithmetic_mean(l)
Rational(23, 3)

Never return a float.

Previous topic

leaftools.multiply

Next topic

listtools.cumulative_products

This Page