Qu

mode

Builtin index · Statistics & ML

result = mode(x)

Input: x · Output: result

What it is

The most frequent value in a numeric or categorical vector x of length N.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = mode(x)
x vectornot documented yet
result scalar
Returns one scalar; ties go to the smallest, matching MATLAB.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

scores = [3, 5, 5, 5, 6, 7, 7, 9, 20]
print("mode: {mode(scores)}")
print("skewness: {round(skewness(scores), 3)}")
print("kurtosis: {round(kurtosis(scores), 3)}")
output
mode: 5
skewness: 1.957
kurtosis: 5.693

from statistics-ml

How it works

mode(x) — the most frequent value, exact-equality grouping (meaningful for discrete/repeated data; a vector of distinct floats has no real mode). Ties broken by the smallest value among them, matching MATLAB's mode.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.