atlas-median
Calculates the median of a set of data points in-place.
install
npm install --save atlas-median
why
Breaking up atlas-dataset into standalone functions. This module computes the median value over an array of numbers:
examples
unsorted array
The median
function sorts the array in-place before taking the middle value. In the case of an even-length array, the median is the mean of the two middle values.
const median = console// 2.5
sorted array
To avoid sorting a pre-sorted array, use a boolean flag:
...const isSorted = true;console // fast// 3