Calculating Median and Mode of a Data Set

Median

Median refers to the midpoint or the middle value of a data set after sorting the values in ascending or descending order.

Our data set sorted in ascending order is presented below:

1.2, 1.5, 1.7, 2.3, 2.5, 2.9, 3, 3.8, 4.2, 4.3, 5.4, 5.5, 5.6, 5.9, 6.2, 6.7, 8.5, 8.8, 9.5, 9.8

Note that our data set has 20 values, so we don’t have one middle point. There are two values namely, 4.3 and 5.4. The median in this case will be the arithmetic mean of these two values.

Median = (4.3+5.4)/2 = 4.85

This will be the case for all data sets containing an even number of observations.

When we have an odd number of observations (such as 5, 7, or 9), the median is simply the middle value. For example in case of 5 observations, the median will be the 3rd value.

Mode

Mode refers to the most frequently occurring value in a data set.

Let’s look at our data set:

1.2, 1.5, 1.7, 2.3, 2.5, 2.9, 3, 3.8, 4.2, 4.3, 5.4, 5.5, 5.6, 5.9, 6.2, 6.7, 8.5, 8.8, 9.5, 9.8

All the values in this data set are different. This means that this data set has no mode.

Let’s look at another data set:

1, 3, 4, 4, 5, 7

In this data set the value 4 occurs twice while the rest of the values occur only once. So, the value 4 has the highest frequency of occurring. The mode of this data set is 4. Such a distribution is called unimodal.

If two values had occurred in the data set with highest frequency, the distribution  will be called bimodal. A data set having 3 values with highest frequency will be called trimodal, and so on. For example, the following data set has value 4 and 5 occurring with highest frequency.

1, 3, 4, 4, 5, 5, 7

Related Downloads

Data Science in Finance: 9-Book Bundle

Data Science in Finance Book Bundle

Master R and Python for financial data science with our comprehensive bundle of 9 ebooks.

What's Included:

  • Getting Started with R
  • R Programming for Data Science
  • Data Visualization with R
  • Financial Time Series Analysis with R
  • Quantitative Trading Strategies with R
  • Derivatives with R
  • Credit Risk Modelling With R
  • Python for Data Science
  • Machine Learning in Finance using Python

Each book includes PDFs, explanations, instructions, data files, and R code for all examples.

Get the Bundle for $39 (Regular $57)
JOIN 30,000 DATA PROFESSIONALS

Free Guides - Getting Started with R and Python

Enter your name and email address below and we will email you the guides for R programming and Python.

Data Science in Finance: 9-Book Bundle

Data Science in Finance Book Bundle

Master R and Python for financial data science with our comprehensive bundle of 9 ebooks.

What's Included:

  • Getting Started with R
  • R Programming for Data Science
  • Data Visualization with R
  • Financial Time Series Analysis with R
  • Quantitative Trading Strategies with R
  • Derivatives with R
  • Credit Risk Modelling With R
  • Python for Data Science
  • Machine Learning in Finance using Python

Each book comes with PDFs, detailed explanations, step-by-step instructions, data files, and complete downloadable R code for all examples.