Skip to main content

Basics

This section focuses on descriptive statistics.

Our data is a one-dimensional array of numbers. For example, we have the following array of numbers: arr = [1.2, 1.5, 1.7, 1.9, 2.0, 2.1, 10.5]

Mean

Mean is the average of the numbers in the array. It is calculated by summing all the numbers and dividing by the count of numbers.

mean = sum(arr) / len(arr)

Median

Median is the middle value of the numbers in the array when they are sorted in ascending order. If the count of numbers is odd, the median is the middle number. If the count is even, the median is the average of the two middle numbers.

Median is considered a better measure of central tendency than mean when the data has outliers, as it is less affected by extreme values.

Mode

Mode is the number that appears most frequently in the array. An array can have no mode, one mode, or multiple modes.