Ten days of statistics (1) - Mean, Median, Mode


The average of all the integers in a set of nn values. Formally:

μ=i=1nxin\mu = \frac{\sum_{i=1}^n x_i}{n}

Where xix_i is the ithi^{th} element of the set

Weighted mean

Given a discrete set of numbers XX, and a corresponding set of weights WW, the weighted mean is calculated as follows:

μw=i=1n(xi×wi)i=1nwi\mu_w = \frac{\sum_{i=1}^n (x_i \times w_i)}{\sum_{i=1}^n w_i}

Where xix_i, wiw_i is the value and weight for element ithi^{th} of the set


The midpoint value of a data set for which an equal number of samples are less than and greater than the value.

For an odd sample size, this is the middle element of the sorted sample

m=xi÷2m = x_{i \div 2}

For an even sample size, this is the average of the 2 middle elements of the sorted sample

m=x(i1)÷2+x(i+1)÷22m = \frac{x_{(i-1) \div 2} + x_{(i+1) \div 2}}{2}


The element(s) that occur most frequently in a data set. For the set {1,1,1,1,1,1,2,3,3,4,9}\{1,1,1,1,1,1,2,3,3,4,9\}, the mode is 11. For the set {1,2,3}\{1,2,3\}, every number in the set is a valid mode.

Application of mean, median and mode


Human Resource managers often calculate the mean salary of individuals in a certain rank so they can know how much salary to offer to new employees.


Human Resource managers also often calculate the median salary so that they can be informed of what the typical “middle” salary is for a particular rank. Median is less influenced by outliers (few extraordinary talented individuals with super high salary) so it is sometimes more accurate than mean value.


Real estate agents often calculate the mode number of bedrooms per house, so they can inform their clients on how many bedrooms they can expect to have in houses in a particular area.


Hackerrank has some exercises for you to test your knowledge:

Next lesson: Quatiles, Standard Deviation

That's all! Thank you for reading all the way here 😊

Made with love using Svelte, Three.js, TailwindCSS