# atlas-median

> Calculates the median of a set of data points in-place.

Latest version **1.0.1** (published 2018-07-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install atlas-median
pnpm add atlas-median
yarn add atlas-median
bun add atlas-median
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-07-16 |
| First published | 2018-07-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^10.1.0 |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | atlassubbed |
| Maintainers | atlassubbed |
| Keywords | atlassubbed, math, stats, utils, utility, arithmetic, helpers, statistics, median, middle |

## Links

- npm: https://www.npmjs.com/package/atlas-median
- Repository: https://github.com/atlassubbed/atlas-median
- Homepage: https://github.com/atlassubbed/atlas-median#readme
- Issues: https://github.com/atlassubbed/atlas-median/issues
- npm.io page: https://npm.io/package/atlas-median

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-07-16
- 1.0.0 — 2018-07-16

## README

# atlas-median

Calculates the median of a set of data points in-place.

[![Travis](https://img.shields.io/travis/atlassubbed/atlas-median.svg)](https://travis-ci.org/atlassubbed/atlas-median)

---

## install

```
npm install --save atlas-median
```

## why

Breaking up [atlas-dataset](https://github.com/atlassubbed/atlas-dataset#readme) into standalone functions. This module computes the median value over an array of numbers:

<p align="center">
  <img alt="median(V) = (v[ceil(|V|/2)] + v[ceil((|V|+1)/2)])/2" src="docs/median.png">
</p>

## 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.

```javascript
const median = require("atlas-median")
console.log(median([4,3,1,2]))
// 2.5
```

#### sorted array

To avoid sorting a pre-sorted array, use a boolean flag:

```javascript
...
const isSorted = true;
console.log(median([1,2,3,4,5], isSorted)) // fast
// 3
```

---
_Source: https://npm.io/package/atlas-median · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
