array-normalize
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/array-normalize package

2.0.0 • Public • Published

array-normalize experimental Build Status

Normalize array to unit length, that is 0..1 range. See feature scaling.

npm install array-normalize

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.

Package Sidebar

Install

npm i array-normalize

Weekly Downloads

187,809

Version

2.0.0

License

MIT

Unpacked Size

7.19 kB

Total Files

8

Last publish

Collaborators

  • dfcreative
  • dy