math:mode( $arg as xs:anyAtomicType*, [$options as xs:string*] ) as xs:anyAtomicType*
Returns the mode of a sequence. The mode is the value that occurs most frequently in a data set. If no value occurs more than once in the data set, the function returns the empty sequence. If the input is the empty sequence, the function returns the empty sequence.
Note that a data set can have multiple “modes”. The order of multiple modes in the returned sequence is undefined.
Also note that values from a lexicon lookup are repeated
cts:frequency
times before calculating the mode.
The function can be used on numeric values, xs:yearMonthDuration
,
xs:dayTimeDuration
, xs:string
,
xs:anyURI
, xs:date
,
xs:dateTime
, xs:time
,
and cts:point
.
math:mode((1,2,2,3,2,3,4,6,7,7,7)) => 2 7