This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

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.
  • 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.
Obtain the elements with the highest frequency:
Obtain the 4 most common elements:
Obtain the elements with the highest frequency:
In[1]:=
Click for copyable input
Out[1]=
 
Obtain the 4 most common elements:
In[1]:=
Click for copyable input
Out[1]=
Elements of the list can be any expressions:
Find the mode of a set of random integers:
Find the most frequently occurring elements in the columns of a matrix:
Commonest gives elements with the largest Tally values:
A message is generated if there are fewer distinct elements than requested:
New in 6