MCPcopy Index your code
hub / github.com/clips/pattern / moment

Function moment

pattern/metrics.py:596–603  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

594#--- MOMENT ----------------------------------------------------------------------------------------
595
596def 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
605def skewness(list):
606 """ Returns the degree of asymmetry of the given list of values:

Callers 3

skewnessFunction · 0.85
kurtosisFunction · 0.85
skewnessMethod · 0.85

Calls 3

sumFunction · 0.85
lenFunction · 0.85
meanFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…