Returns the variance of the given list of values. The variance is the average of squared deviations from the mean.
(list, sample=True)
| 554 | return s[n/2] |
| 555 | |
| 556 | def variance(list, sample=True): |
| 557 | """ Returns the variance of the given list of values. |
| 558 | The variance is the average of squared deviations from the mean. |
| 559 | """ |
| 560 | # Sample variance = E((xi-m)^2) / (n-1) |
| 561 | # Population variance = E((xi-m)^2) / n |
| 562 | m = mean(list) |
| 563 | return sum((x-m)**2 for x in list) / (len(list)-int(sample) or 1) |
| 564 | |
| 565 | def standard_deviation(list, *args, **kwargs): |
| 566 | """ Returns the standard deviation of the given list of values. |
no test coverage detected
searching dependent graphs…