ML | Raw materials and focal points

Python Methods and Functions

For ungrouped data, i.e. discrete data, observations on the X variable are obtained as , For grouped data, that is, continuous data, observations on the variable X is obtained and tabulated with an interval of K classes in the frequency table. The middle of inertia is indicated by which occur with frequencies respectively and ,

Class Intervals Mid Points ( ) Absolute Frequency ( )

Moments about arbitrary point A
moment of variable X about arbitrary point A on observations is defined as:

For ungrouped data

For grouped data

where

A moment about any arbitrary point in Python —

Consider these points. Below is the time (in hours) that 20 different people spend on Python.Engineering every week.

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

# data points

time = [ 15 , 25 , 18 , 36 , 40 , 28 , 30 , 32 , 23 , 22

21 , 27 , 31 , 20 , 14 , 10 , 33 , 11 , 7 , 13 ]

 
# Arbitrary dot

A = 22

 
# Moment for r = 1

moment = ( sum ([(item - A) for item in time])) / len (time)




Raw Moments —

moment around source A = 0 known as a raw moment and defined as:

For ungrouped data,
For grouped data,

where,

Notes :

- & gt;  We can find first raw moment ( ) just by replacing r with 1 and second raw moment ( ) just by replacing r with 2 and so on.
- & gt;  When r = 0 the moment for both grouped and ungrouped data.

Raw moment in Python —

# data points

time = [ 15 , 25 , 18 , 36 , 40 , 28 , 30 , 32 , 23 ,

22 , 21 , 27 , 31 , 20 , 14 , 10 , 33 , 11 , 7 , 13 ]

 

  
# A moment for g = 1

moment = sum (time) / len (time)




Central moments —

The moments of the X variable relative to the arithmetic mean () are known as pivot moments and are defined as:

For ungrouped data,

For grouped data,

where and

Notes :

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

Relationship between Raw and Central Moments —





Get Solution for free from DataCamp guru

# data points

time = [ 15 , 25 , 18 , 36 , 40 , 28 , 30 , 32 , 23 , 22 ,

21 , 27 , 31 , 20 , 14 , 10 , 33 , 11 , 7 , 13 ]

 
# Greedy

A = sum (time) / len (time)

  
# Moment for r = 1

moment = ( sum ([(item - A) for item in time])) / len (time)