ML | Raw and Central Moments

Moments are a set of statistical parameters which are used to describe different characteristics and feature of a frequency distribution i.e. central tendency, dispersion, symmetry, and peakedness (hump) of the frequency curve.

For Ungrouped data i.e. discrete data, observations on a variable X are obtained as x_1, x_2, x_3, ...., x_n, For Grouped data i.e. continuous data, observations on a variable X are obtained and tabulated in K class intervals in a frequency table. The mid points of the inervals are denoted by x_1, x_2, x_3, ...., x_n which occur with frequencies f_1, f_2, f_3, ...., f_n respectively and n=f_1, f_2, f_3, ...., f_n.

Class Intervals Mid Points (x_i) Absolute Frequency (f_i)
c_1 - c_2 x_1 = (c_1 + c_2)/2 f_1
c_2 - c_3 x_2 = (c_2 + c_3)/2 f_2
c_3 - c_4 x_3 = (c_3 + c_4)/2 f_3
c_k_-_1 - c_k x_k = (c_k_-_1 + c_k)/2 f_k

Moments about an arbitrary point A
The r^t^h moment of a variable X about any arbitrary point A on the observations x_1, x_2, x_3, ...., x_n is defined as:



For ungrouped data  \mu^'_r = \frac{1}{n}\sum_{i=1}^{n}(x_i - A)^r

For grouped data  \mu^'_r = \frac{1}{n}\sum_{i=1}^{n}f_i(x_i - A)^r

where
 n = \sum_{i=1}^{k}f_i

 
Moment about any arbitrary point in Python –

Consider the given data points. Following are the time (in hours) spent by 20 different persons at GeeksforGeeks portal every week.

15, 25, 18, 36, 40, 28, 30, 32, 23, 22, 21, 27, 31, 20, 14, 10, 33, 11, 7, 13
filter_none

edit
close

play_arrow

link
brightness_4
code

# data points
time = [15, 25, 18, 36, 40, 28, 30, 32, 23, 22
        21, 27, 31, 20, 14, 10, 33, 11, 7, 13]
  
# Arbitrary point 
A = 22
  
# Moment for r = 1
moment = (sum([(item-A) for item in time]))/len(time)

chevron_right


Raw Moments –

The r^t^h moment around origin A = 0 known as raw moment and is defined as:

For ungrouped data, \mu^'_r = \frac{1}{n}\sum_{i=1}^{n}x_i^r
For grouped data,  \mu^'_r = \frac{1}{n}\sum_{i=1}^{n}f_i x_i^r

where, n = \sum_{i=1}^{k}f_i

Notes:

-> We can find first raw moment (\mu^'_1) just by replacing r with 1 and second raw moment (\mu^'_2) just by replacing r with 2 and so on.
-> When r = 0 the moment \mu^'_0 = 1 for both grouped and ungrouped data.


 
Raw moment in Python –

filter_none

edit
close

play_arrow

link
brightness_4
code

# data points
time = [15, 25, 18, 36, 40, 28, 30, 32, 23,
       22, 21, 27, 31, 20, 14, 10, 33, 11, 7, 13]
  
  
# Moment for r = 1
moment = sum(time)/len(time)

chevron_right


Central Moments –

The moments of a variable X about the arithmetic mean (\overline{x}) are known as central moments and defined as:

For ungrouped data,\mu_r = \frac{1}{n}\sum_{i=1}^{n}(x_i-\overline{x})^r

For grouped data,\mu_r = \frac{1}{n}\sum_{i=1}^{n}f_i (x_i-\overline{x})^r

where n = \sum_{i=1}^{k}f_i and  \overline{x} = \sum_{i=1}^{k}f_ix_i

Notes:

-> We can find first raw moment (\mu_1) just by replacing r with 1 and second raw moment (\mu_2) just by replacing r with 2 and so on.
-> When r = 0 the moment \mu_0 = 1, and when r = 1 the moment \mu_1 = 0 for both grouped and ungrouped data.

filter_none

edit
close

play_arrow

link
brightness_4
code

# data points
time = [15, 25, 18, 36, 40, 28, 30, 32, 23, 22,
       21, 27, 31, 20, 14, 10, 33, 11, 7, 13]
  
# Mean 
A = sum(time)/len(time)
  
# Moment for r = 1
moment = (sum([(item-A) for item in time]))/len(time)

chevron_right


 
Relationship between Raw and Central moments –



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.