Commonest

Commonest[list]

gives a list of the elements that are the most common in list.

Commonest[list,n]

gives a list of the n most common elements in list.

Details

  • When several elements occur with equal frequency, Commonest[list,] picks first the ones that occur first in list.
  • Commonest[list,n] returns the n commonest elements in the order they appear in list.
  • Commonest[list,UpTo[n]] returns the n commonest elements, or as many as are available.

Examples

open allclose all

Basic Examples  (3)

Obtain the elements with the highest frequency:

Obtain the 4 most common elements:

Obtain the 6 most common elements, or as many as there are if fewer:

Scope  (4)

Exact input yields exact output:

Approximate input yields approximate output:

Works with large arrays:

Works with data involving quantities:

Applications  (2)

Find the mode of a set of random integers:

Find the most frequently occurring elements in the columns of a matrix:

Find the mode for the heights of the children in a class:

Properties & Relations  (1)

Commonest gives elements with the largest Tally values:

Possible Issues  (1)

A message is generated if there are fewer distinct elements than requested:

Wolfram Research (2007), Commonest, Wolfram Language function, https://reference.wolfram.com/language/ref/Commonest.html (updated 2015).

Text

Wolfram Research (2007), Commonest, Wolfram Language function, https://reference.wolfram.com/language/ref/Commonest.html (updated 2015).

BibTeX

@misc{reference.wolfram_2021_commonest, author="Wolfram Research", title="{Commonest}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Commonest.html}", note=[Accessed: 01-August-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_commonest, organization={Wolfram Research}, title={Commonest}, year={2015}, url={https://reference.wolfram.com/language/ref/Commonest.html}, note=[Accessed: 01-August-2021 ]}

CMS

Wolfram Language. 2007. "Commonest." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Commonest.html.

APA

Wolfram Language. (2007). Commonest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Commonest.html