ml-array-utils
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"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); | ||
}); | ||
}); |
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
24026
569
134