📊 Statistics Module
Last Updated: 24th August 2025
The statistics module provides a set of functions for performing statistical calculations. It includes functions for basic statistics, such as mean, median, mode, standard deviation, and more.
List of Statistics Functions:
- mean(data): Returns the arithmetic mean(Average) of the data.
import statistics as stats
data = [10, 20, 30, 40, 50]
print(stats.mean(data)) # 30
- median(data): Returns the median value of the data.
import statistics as stats
print(stats.median([10, 20, 30])) # 20
print(stats.median([10, 20, 30, 40])) # (20+30)/2 = 25
- median_low(data)/median_high(data): Returns the lower/upper median value of the data.
import statistics as stats
print(stats.median_low([10, 20, 30, 40])) # 20
print(stats.median_high([10, 20, 30, 40])) # 30
- mode(data): Returns the most frequently occurring value in the data.
import statistics as stats
print(stats.mode([1, 2, 2, 3, 3, 4])) # 2
- variance(data): Returns the variance of the data.
import statistics as stats
print(stats.variance([1, 2, 3, 4, 5])) # 2.5
- stdev(data): Returns the standard deviation of the data.
import statistics as stats
print(stats.stdev([1, 2, 3, 4, 5])) # 1.581114
- quartiles(data): Returns the quartiles of the data.
import statistics as stats
print(stats.quantiles([1,2,3,4,5,6,7,8,9], n=4))
# [2.5, 5.0, 7.5] (quartiles)