arithmetic_mean
arithmetic_mean
dumbpy.arithmetic_mean
Compute the arithmetic mean of numeric values.
The input may be a nested iterable; nesting is flattened via :func:dumbpy.support_functions.validate_list.
Functions
| Name | Description |
|---|---|
| arithmetic_mean | Compute the arithmetic mean of numeric values. |
arithmetic_mean
arithmetic_mean.arithmetic_mean(values)Compute the arithmetic mean of numeric values.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| values | Iterable[Any] | A (possibly nested) iterable containing numeric values. | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | The arithmetic mean of the numeric values. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If the flattened input contains no elements. | |
| TypeError | If the input is not a valid iterable for flattening, or if any element is non-numeric (raised by :func:validate_list). |
Examples
>>> arithmetic_mean([1, 2, 3, 4])
2.5
>>> arithmetic_mean([1, [2, 3]])
2.0