# mode

Most frequent values in array

## Syntax

## Description

returns
the sample mode of `M`

= mode(`A`

)`A`

, which is the most frequently
occurring value in `A`

. When there are multiple values
occurring equally frequently, `mode`

returns the
smallest of those values. For complex inputs, the smallest value is
the first value in a sorted list.

If

`A`

is a vector, then`mode(A)`

returns the most frequent value of`A`

.If

`A`

is a nonempty matrix, then`mode(A)`

returns a row vector containing the mode of each column of`A`

.If

`A`

is an empty 0-by-0 matrix,`mode(A)`

returns`NaN`

.If

`A`

is a multidimensional array, then`mode(A)`

treats the values along the first array dimension whose size does not equal`1`

as vectors and returns an array of most frequent values. The size of this dimension becomes`1`

while the sizes of all other dimensions remain the same.If

`A`

is a table or timetable, then`mode(A)`

returns a one-row table containing the mode of each variable.*(since R2023a)*

## Examples

## Input Arguments

## Output Arguments

## Tips

The

`mode`

function is most useful with discrete or coarsely rounded data. The mode for a continuous probability distribution is defined as the peak of its density function. Applying the`mode`

function to a sample from that distribution is unlikely to provide a good estimate of the peak; it would be better to compute a histogram or density estimate and calculate the peak of that estimate. Also, the`mode`

function is not suitable for finding peaks in distributions having multiple modes.

## Extended Capabilities

## Version History

**Introduced before R2006a**

## See Also

`mean`

| `median`

| `histogram`

| `histcounts`

| `sort`