Returns the value that separates the lower half from the higher half of values in the list.
(list)
| 543 | avg = mean |
| 544 | |
| 545 | def median(list): |
| 546 | """ Returns the value that separates the lower half from the higher half of values in the list. |
| 547 | """ |
| 548 | s = sorted(list) |
| 549 | n = len(list) |
| 550 | if n == 0: |
| 551 | raise ValueError, "median() arg is an empty sequence" |
| 552 | if n % 2 == 0: |
| 553 | return float(s[(n/2)-1] + s[n/2]) / 2 |
| 554 | return s[n/2] |
| 555 | |
| 556 | def variance(list, sample=True): |
| 557 | """ Returns the variance of the given list of values. |
nothing calls this directly
no test coverage detected
searching dependent graphs…