Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Statistics - Mode


The mode is a type of average value, which describes where most of the data is located.


Mode

The mode is the value(s) that are the most common in the data.

A dataset can have multiple values that are modes.

A distribution of values with only one mode is called unimodal.

A distribution of values with two modes is called bimodal. In general, a distribution with more than one mode is called multimodal.

Mode can be found for both categorical and numerical data.


Finding the Mode

Here is a numerical example:

4, 7, 3, 8, 11, 7, 10, 19, 6, 9, 12, 12

Both 7 and 12 appears two times each, and the other values only once. The modes of this data is 7 and 12.

Here is a categorical example with names:

Alice, John, Bob, Maria, John, Julia, Carol

John appears two times, and the other values only once. The mode of this data is John.


Finding the Mode with Programming

The mode can easily be found with many programming languages.

Using software and programming to calculate statistics is more common for bigger sets of data, as calculating manually becomes difficult.

Example

With Python use the statistics library multimode() method to find the modes of the values 4,7,3,8,11,7,10,19,6,9,12,12:

from statistics import multimode

values = [4,7,3,8,11,7,10,19,6,9,12,12]

x = multimode(values)

print(x)
Try it Yourself »

Example

Using R with a user-defined function to find the modes of the values 4,7,3,8,11,7,10,19,6,9,12,12:

mode <- function(x) {
  unique_values <- unique(x)
  table <- tabulate(match(x, unique_values))
  unique_values[table == max(table)]
}

values <- c(4,7,3,8,11,7,10,19,6,9,12,12)

mode(values)
Try it Yourself »

Note: R has no built-in function to find the mode.


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.