แก้ coding style ภาค 10
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @param {array} nodes
|
||||
* @return {object} that contains the normalization parameters.
|
||||
*/
|
||||
function calculateNormalization(nodes) {
|
||||
function calculateNormalization (nodes) {
|
||||
var STANDARD_DEV = 2.0,
|
||||
properties = Object.keys(nodes[0]),
|
||||
sums = calculateSums(nodes, properties),
|
||||
@@ -23,10 +23,8 @@ function calculateNormalization(nodes) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function standardDevation(nodes, properties, avg) {
|
||||
|
||||
var stDev = new Array(properties.length).fill(0)
|
||||
function standardDevation (nodes, properties, avg) {
|
||||
var stDev = new Array(properties.length).fill(0);
|
||||
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
var sum = 0;
|
||||
@@ -48,11 +46,10 @@ function standardDevation(nodes, properties, avg) {
|
||||
sum += Math.pow(val - propAvg, 2);
|
||||
});
|
||||
|
||||
stDev[i] = Math.sqrt(sum/nodes.length);
|
||||
stDev[i] = Math.sqrt(sum / nodes.length);
|
||||
}
|
||||
|
||||
return stDev;
|
||||
|
||||
return stDev;
|
||||
}
|
||||
|
||||
// Calculate the sum of values and the squared sum
|
||||
@@ -63,7 +60,7 @@ function standardDevation(nodes, properties, avg) {
|
||||
* @return {object} that contains arrays with sum of values
|
||||
* and the squared sums.
|
||||
*/
|
||||
function calculateSums(nodes, properties) {
|
||||
function calculateSums (nodes, properties) {
|
||||
var sumOfValues = new Array(properties.length).fill(0),
|
||||
sumOfSquares = new Array(properties.length).fill(0);
|
||||
|
||||
@@ -90,4 +87,4 @@ function calculateSums(nodes, properties) {
|
||||
sumOfVal: sumOfValues,
|
||||
sumOfSq: sumOfSquares
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user