Python Statistics Module
Functions for Statistical Calculations:
statistics.mean()
: Calculates the arithmetic mean of a sequence of numbers.statistics.median()
: Calculates the median of a sequence of numbers.statistics.mode()
: Calculates the mode of a sequence of numbers.statistics.stdev()
: Calculates the standard deviation of a sample of numbers.statistics.variance()
: Calculates the variance of a sample of numbers.statistics.harmonic_mean()
: Calculates the harmonic mean of a sequence of numbers.statistics.median_low()
: Calculates the low median of a sequence of numbers.statistics.median_high()
: Calculates the high median of a sequence of numbers.statistics.median_grouped()
: Calculates the median of grouped continuous data.
Additional Statistical Functions:
statistics.pstdev()
: Calculates the population standard deviation of a sample of numbers.statistics.pvariance()
: Calculates the population variance of a sample of numbers.statistics.quantiles()
: Calculates the specified quantiles of a sequence of numbers.statistics.bisect_left()
: Locates the insertion point for a value in a sorted sequence.statistics.bisect_right()
: Locates the insertion point after a value in a sorted sequence.
Statistical Constants:
statistics.StatisticalError
: Exception raised for statistical errors.
Example of Usage:
import statistics
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Mean
mean_value = statistics.mean(data)
# Median
median_value = statistics.median(data)
# Mode
mode_value = statistics.mode(data)
# Standard Deviation
std_deviation = statistics.stdev(data)
# Variance
variance_value = statistics.variance(data)
# Harmonic Mean
harmonic_mean_value = statistics.harmonic_mean(data)
# Other statistical calculations can be performed similarly
These functions cover a wide range of statistical calculations, enabling users to perform various analyses on datasets efficiently using Python's statistics
module.