# array-normalize

> Normalize array (possibly n-dimensional) to zero mean and unit variance

Latest version **2.0.0** (published 2020-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install array-normalize
pnpm add array-normalize
yarn add array-normalize
bun add array-normalize
```

## Health

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

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-12-22 |
| First published | 2017-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/array-normalize) |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dima Iv |
| Maintainers | dfcreative, dy |
| Keywords | array, normalize, normal, statistics, samples |

## Links

- npm: https://www.npmjs.com/package/array-normalize
- Repository: https://github.com/dy/array-normalize
- Homepage: https://github.com/dy/array-normalize#readme
- Issues: https://github.com/dy/array-normalize/issues
- npm.io page: https://npm.io/package/array-normalize

## Dependencies (1)

- [array-bounds](https://npm.io/package/array-bounds.md) ^1.0.0

## Recent versions

- 2.0.0 (latest) — 2020-12-22
- 1.1.4 — 2019-10-28
- 1.1.3 — 2017-07-12
- 1.1.2 — 2017-06-01
- 1.1.1 — 2017-05-31
- 1.1.0 — 2017-05-31
- 1.0.1 — 2017-01-24
- 1.0.0 — 2017-01-24

## README

# array-normalize  [![experimental](https://img.shields.io/badge/stability-unstable-yellow.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dy/array-normalize.svg)](https://travis-ci.com/dy/array-normalize)

Normalize array to unit length, that is 0..1 range. See [feature scaling](https://en.wikipedia.org/wiki/Feature_scaling).

[![npm install array-normalize](https://nodei.co/npm/array-normalize.png?mini=true)](https://npmjs.org/package/array-normalize/)

```js
const normalize = require('array-normalize')

normalize([0, 50, 100]) // [0, .5, 1]
normalize([0, 0, .1, .2, 1, 2], 2) // [0, 0, .1, .1, 1, 1]
normalize([0, .25, 1, .25], 2, [0, .5, 1, .5]) // [0, .5, 1, .5])
```

## API

### array = normalize(array, stride=1, bounds?)

Normalizes n-dimensional array in-place using optional stride for n-dimensions, ie. for 2d data layout is `[x, y, x, y, ...]`.

Every dimension is normalized independently, eg. 2d array is normalized to unit square `[0, 0, 1, 1]`.

Optional `bounds` box can predefine min/max to skip bounds detection.

<p align="center">ॐ</p>

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