maths.average_absolute_deviation

Functions

average_absolute_deviation(→ float)

Return the average absolute deviation of a list of numbers.

Module Contents

maths.average_absolute_deviation.average_absolute_deviation(nums: list[int]) float

Return the average absolute deviation of a list of numbers. Wiki: https://en.wikipedia.org/wiki/Average_absolute_deviation

>>> average_absolute_deviation([0])
0.0
>>> average_absolute_deviation([4, 1, 3, 2])
1.0
>>> average_absolute_deviation([2, 70, 6, 50, 20, 8, 4, 0])
20.0
>>> average_absolute_deviation([-20, 0, 30, 15])
16.25
>>> average_absolute_deviation([])
Traceback (most recent call last):
    ...
ValueError: List is empty