Returns the arithmetic mean of the given list of values. For example: mean([1,2,3,4]) = 10/4 = 2.5.
(list)
| 530 | #--- MEAN ------------------------------------------------------------------------------------------ |
| 531 | |
| 532 | def mean(list): |
| 533 | """ Returns the arithmetic mean of the given list of values. |
| 534 | For example: mean([1,2,3,4]) = 10/4 = 2.5. |
| 535 | """ |
| 536 | s = 0 |
| 537 | n = 0 |
| 538 | for x in list: |
| 539 | s += x |
| 540 | n += 1 |
| 541 | return float(s) / (n or 1) |
| 542 | |
| 543 | avg = mean |
| 544 |