Skip to main content
Module

x/simplestatistic/src/mode_fast.js>default

simple statistics for node & browser javascript
function default
import { default } from "https://deno.land/x/simplestatistic@v7.7.1/src/mode_fast.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.

modeFast uses a Map object to keep track of the mode, instead of the approach used with mode, a sorted array. As a result, it is faster than mode and supports any data type that can be compared with ==. It also requires a JavaScript environment with support for Map, and will throw an error if Map is not available.

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

Examples

modeFast(['rabbits', 'rabbits', 'squirrels']); // => 'rabbits'

Parameters

x

a sample of one or more data points