Commonest
Examples
open all close allBasic Examples (3)
Obtain the elements with the highest frequency:
Commonest[{b, a, c, 2, a, b, 1, 2}]Obtain the 4 most common elements:
Commonest[{b, a, c, 2, a, b, 1, 2}, 4]Obtain the 6 most common elements, or as many as there are if fewer:
Commonest[{b, a, c, 2, a, b, 1, 2}, UpTo[6]]Scope (4)
Exact input yields exact output:
Commonest[{1, 2, 2, 3, 3, 3, 4}]Commonest[{a, E, Sin[y], E, a, 7}]Approximate input yields approximate output:
Commonest[N[{1, 2, 2, 3, 3, 3, 4}]]Commonest[N[{1, 2, 2, 3, 3, 3, 4}, 30]]Commonest[Join[Table[1, {10 ^ 7}], Table[3, {10 ^ 4}], {7, 8}]]Commonest[Join[Table[1, {10 ^ 7}], Table[3, {10 ^ 4}], {7, 8}], 2]Works with data involving quantities:
data = Quantity[{1, 2, 2, 3, 3, 3, 4}, "Meters"]Commonest[data]Applications (2)
Find the mode of a set of random integers:
Commonest[RandomInteger[20, 1000]]Find the most frequently occurring elements in the columns of a matrix:
Map[Commonest, Transpose[RandomInteger[20, {1000, 5}]]]Find the mode for the heights of the children in a class:
heights = Quantity[{134, 143, 131, 140, 145, 136, 131, 136, 143, 136, 133, 145, 147,
150, 150, 146, 137, 143, 132, 142, 145, 136, 144, 135, 141}, "Centimeters"];ListPlot[heights, Filling -> Axis, AxesLabel -> Automatic]Commonest[heights]mode = %[[1]]ListPlot[{heights, {{0, mode}, {Length[heights], mode}}}, Joined -> {False, True}, Filling -> {1 -> 0}, AxesLabel -> Automatic]Properties & Relations (1)
See Also
Counts Tally Median Mean Split CommonestFilter
Function Repository: Rarest StatisticsSummary
Related Workflows
- Analyze a Computable Dataset
Text
Wolfram Research (2007), Commonest, Wolfram Language function, https://reference.wolfram.com/language/ref/Commonest.html (updated 2015).
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
BibTeX
@misc{reference.wolfram_2026_commonest, author="Wolfram Research", title="{Commonest}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Commonest.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_commonest, organization={Wolfram Research}, title={Commonest}, year={2015}, url={https://reference.wolfram.com/language/ref/Commonest.html}, note=[Accessed: 12-June-2026]}