Calculate Mode Of A Distribution Using Python

Mode of a Distribution:

The most commonly occurring value in a distribution is called the modal value or simply the mode. It is possible that a distribution has no mode at all or more than one mode.

A distribution that has one most occurring value is called unimodal.

A distribution with two most occurring value has two modes and is called bimodal and one with three modes is called trimodal.

Mode is one of the measures of central tendancy.

Method Name:


Method Overview:

The Python mode() function takes data from any sequence or iterator type and returns the most occurring value in the data.


  • The mode function will return the modal value only if the distribution has a unique mode. If the distribution has multiple modes, python raises StatisticsError; For Example, the mode() function will report  “no unique mode; found 2 equally common values” when it is supplied of a bimodal distribution.  
  • If the parameter supplied to the mode function is found empty python raises a StatisticsError stating “statistics.StatisticsError: no mode for empty data”


Example Python Program to find Mode of a distribution:


#import the python statistics module

import statistics


# Define data points

dataPoints  = [1,2,3,4,5,5,5,6,7,8]


# Find mode - the most occurring value in a distribution

mode        = statistics.mode(dataPoints)

print("Mode of the distribution is {}".format(mode))

Output of the Python Program that finds the Mode of a distribution:

Mode of the distribution is 5


Copyright 2023 ©