Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dy/array-normalize
Normalize array to zero mean and unit variance
https://github.com/dy/array-normalize
array dsp math statistics
Last synced: 10 days ago
JSON representation
Normalize array to zero mean and unit variance
- Host: GitHub
- URL: https://github.com/dy/array-normalize
- Owner: dy
- License: mit
- Created: 2017-01-24T13:31:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-12T21:14:31.000Z (4 months ago)
- Last Synced: 2024-10-20T12:55:37.950Z (17 days ago)
- Topics: array, dsp, math, statistics
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
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.
ॐ