Returns the kth central moment of the given list of values (2nd central moment = variance, 3rd and 4th are used to define skewness and kurtosis).
(list, k=1)
| 594 | #--- MOMENT ---------------------------------------------------------------------------------------- |
| 595 | |
| 596 | def moment(list, k=1): |
| 597 | """ Returns the kth central moment of the given list of values |
| 598 | (2nd central moment = variance, 3rd and 4th are used to define skewness and kurtosis). |
| 599 | """ |
| 600 | if k == 1: |
| 601 | return 0.0 |
| 602 | m = mean(list) |
| 603 | return sum([(x-m)**k for x in list]) / (len(list) or 1) |
| 604 | |
| 605 | def skewness(list): |
| 606 | """ Returns the degree of asymmetry of the given list of values: |