Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-normalize

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-normalize - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

0

.eslintrc.json

@@ -0,0 +0,0 @@ {

4

index.js

@@ -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])
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc