array-normalize
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -0,0 +0,0 @@ { |
@@ -34,3 +34,5 @@ 'use strict' | ||
for (i = offset; i < l; i+=dim) { | ||
arr[i] = range === 0 ? .5 : (arr[i] - min) / range | ||
if (!isNaN(arr[i])) { | ||
arr[i] = range === 0 ? .5 : (arr[i] - min) / range | ||
} | ||
} | ||
@@ -37,0 +39,0 @@ } |
{ | ||
"name": "array-normalize", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Normalize array (possibly n-dimensional) to zero mean and unit variance", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,2 +11,4 @@ # 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/dfcreative/array-normalize.svg)](https://travis-ci.org/dfcreative/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]) | ||
``` | ||
@@ -16,4 +18,8 @@ | ||
### array = normalize(array, n=1, bounds?) | ||
### array = normalize(array, dimensions=1, bounds?) | ||
Normalizes n-dimensional array in-place using dimensions `n` as stride, ie. for 1d array the expected data layout is `[x, x, x, ...]` for 2d is `[x, y, x, y, ...]`, etc. Every dimension is normalized independently, so 2d array is normalized to unit square `[0, 0, 1, 1]`. Optionally pass `bounds` box if you know min/max values to optimize calculations. | ||
Normalizes n-dimensional array in-place using `dimensions` as stride, ie. for 1d array the expected data layout is `[x, x, x, ...]` for 2d is `[x, y, x, y, ...]`, etc. | ||
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 optimize calculations. |
@@ -24,1 +24,4 @@ 'use strict' | ||
assert.deepEqual(norm(f, 2, [0, .5, 1, .5]), [0, .5, 1, .5]) | ||
let g = [0, 0, NaN, NaN, 1, 1] | ||
assert.deepEqual(norm(g, 2).map(v => isNaN(v) ? -1 : v), [0, 0, -1, -1, 1, 1]) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5150
97
24
6