Statistics for Programmers - Measures of Central Tendency

Central tendency measures are valuable statistical values that shed light on the "typical" or central value around which data tend to cluster. Let's delve into the three primary measures of central tendency: the Mean, Median, and Mode.


The Mean, also known as the average, is the most commonly used measure of central tendency. To calculate it, we sum all the values in a dataset and then divide by the number of data points.

\[ \text{Mean} = \frac{\sum_{i=1}^{n} x_i}{n} \]


  • \( n \) is the total number of data points in the dataset.
  • \( x_i \) represents each data point in the dataset.

The \( \sum \) sign or summation (sum for short), signifies that we want to add up all the values in the series \( x \), which can be expressed as \(x_1 + x_2 + x_3 \ldots \).

Let's see this in action using an array of measurements:

const arr = [80, 95, 93, 95, 5];

By applying the following function, we compute the mean of the values:

This post is for subscribers only

Already have an account? Sign in.

Subscribe to Another Dev's Two Cents

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.