Moment - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To get the n-th moment of a data set.

Code:

>>> from scipy import stat
>>> X = [9.07, 8.97, 6.41, 3.03, 1.19, 2.67, 2.81, 9.2]
>>> result = stats.moment(X, moment=1)
>>> print("First moment = %.2f" % result)
First moment = 0.00
>>> result = stats.moment(X, moment=2)
>>> print("Second moment = %.2f" % result)
Second moment = 9.90
>>> result = stats.moment(X, moment=3)
>>> print("Third moment = %.2f" % result)
Third moment = 2.59