Mean Calculation Using Python

Mean value of a distribution:

Mean of the distribution is the average value of the distribution.

Summing up of all the values of a distribution and dividing the sum by the total number of data items calculate mean of a distribution. Each value present in the distribution contributes in the calculation of the arithmetic mean.

Because all the values are considered while arriving at the average value, any outliers, be very small or very large will affect the average value or mean.

Remember mean value is not the middle value of the distribution, for which you need to use the median.

 

Method Name:

mean(data)

Method Overview:

The python mean() function in the statistics module takes any sequence like list or any iterator type and returns the arithmetic mean() of the associated data.

Example Python program to calculate Arithmetic Mean using statistics module:

import statistics

 

data = [10,15,17,25,30,90,100]

 

arithmeticMean = statistics.mean(data)

 

print("Arithmetic mean of the data is {}".format(arithmeticMean))

 

 

Output of sample Python program that calculates Arithmetic Mean:

 

Arithmetic mean of the data is 41

 

The developer can replace the extreme values to adjust the data and execute the program again to see how extereme values in a distribution affects the value of the arithmetic mean.

 


Copyright 2024 © pythontic.com