Skip to main content
Module

x/simplestatistics/index.js>mode

simple statistics for node & browser javascript
Go to Latest
function mode
import { mode } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

The mode is the number that appears in a list the highest number of times. There can be multiple modes in a list: in the event of a tie, this algorithm will return the most recently seen mode.

This is a measure of central tendency: a method of finding a typical or central value of a set of numbers.

This runs in O(n log(n)) because it needs to sort the array internally before running an O(n) search to find the mode.

Examples

mode([0, 0, 1]); // => 0

Parameters

x

input