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

ml-array-utils

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-array-utils - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "ml-array-utils",
"version": "0.1.2",
"version": "0.1.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -120,9 +120,7 @@ # ArrayUtils

Function that applies the standard normal variate (SNV) to each row vector of y's
values.
Function that applies the standard normal variate (SNV) to an array of values.
__Arguments__
* `results` - object with three values, 'result' with the applied SNV, 'means' with
the means calculated, and 'standardDeviations' calculated by the SNV.
* `data` - array of values.

@@ -129,0 +127,0 @@ ## Authors

@@ -8,22 +8,12 @@ 'use strict';

/**
* Function that applies the standard normal variate (SNV) to each row vector of y's
* values.
* Function that applies the standard normal variate (SNV) to an array of values.
*
* @param data - Matrix of y vectors
* @returns {Object}
* @param data - Array of values.
* @returns {Array} - applied the SNV.
*/
function SNV(data) {
var Y = data;
if(!Matrix.isMatrix(data)) {
Y = new Matrix(data).clone();
}
var mean = Stat.array.mean(data);
var std = Stat.array.standardDeviation(data);
var means = Matrix.columnVector(Stat.matrix.mean(data, 1));
var std = Matrix.columnVector(Stat.matrix.standardDeviation(data.transpose(), means));
return {
result: Y.sub(means.mmul(Matrix.ones(1, Y.columns))).divM(std.mmul(Matrix.ones(1, Y.columns))),
means: means,
standardDeviations: std
};
return new Matrix([data]).clone().sub(mean).div(std).getRow(0);
}

@@ -7,11 +7,10 @@ 'use strict';

it('Main test', function () {
var data = [[0.323, 2.56, 4.67, 13.23],
[1.76, 1.81, 2.20, 2.45]];
var dataNorm = SNV(data).result;
var data = [0.323, 2.56, 4.67, 13.23];
var dataNorm = SNV(data);
dataNorm[0][0].should.be.approximately(-0.8636, 1e-3);
dataNorm[0][3].should.be.approximately(1.4239, 1e-3);
dataNorm[1][0].should.be.approximately(-0.8975, 1e-3);
dataNorm[1][3].should.be.approximately(1.2018, 1e-3);
dataNorm[0].should.be.approximately(-0.8636, 1e-3);
dataNorm[1].should.be.approximately(-0.4671, 1e-3);
dataNorm[2].should.be.approximately(-0.0931, 1e-3);
dataNorm[3].should.be.approximately(1.4239, 1e-3);
});
});
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