Skip to content
Maurice HT Ling edited this page Aug 13, 2021 · 2 revisions

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
Clone this wiki locally