Python Statistics Module

ยท

2 min read

Functions for Statistical Calculations:

  1. statistics.mean(): Calculates the arithmetic mean of a sequence of numbers.

  2. statistics.median(): Calculates the median of a sequence of numbers.

  3. statistics.mode(): Calculates the mode of a sequence of numbers.

  4. statistics.stdev(): Calculates the standard deviation of a sample of numbers.

  5. statistics.variance(): Calculates the variance of a sample of numbers.

  6. statistics.harmonic_mean(): Calculates the harmonic mean of a sequence of numbers.

  7. statistics.median_low(): Calculates the low median of a sequence of numbers.

  8. statistics.median_high(): Calculates the high median of a sequence of numbers.

  9. statistics.median_grouped(): Calculates the median of grouped continuous data.

Additional Statistical Functions:

  1. statistics.pstdev(): Calculates the population standard deviation of a sample of numbers.

  2. statistics.pvariance(): Calculates the population variance of a sample of numbers.

  3. statistics.quantiles(): Calculates the specified quantiles of a sequence of numbers.

  4. statistics.bisect_left(): Locates the insertion point for a value in a sorted sequence.

  5. statistics.bisect_right(): Locates the insertion point after a value in a sorted sequence.

Statistical Constants:

  1. 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.

Did you find this article valuable?

Support Namya Shah by becoming a sponsor. Any amount is appreciated!

ย