Loading TOC...

MarkLogic 9 Product Documentation
math:mode

math:mode(
   $arg as xs:anyAtomicType*,
   [$options as xs:string*]
) as xs:anyAtomicType*

Summary

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.

Parameters
arg The sequence of values.
options Options. The default is ().

Options include:

"collation=URI"
Applies only when $arg is of the xs:string type. If no specified, the default collation is used.
"coordinate-system=name"
Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used.

Example

  math:mode((1,2,2,3,2,3,4,6,7,7,7))

  => 2 7

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.