array-normalize
![Build Status](https://camo.githubusercontent.com/5d137b9d543750b135087fb8afff19f0c7f39b17be80b65d7cb9f498b1ba60c0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64792f61727261792d6e6f726d616c697a652e737667)
Normalize array to unit length, that is 0..1 range. See feature scaling.
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.
ॐ