MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / stddev

Function stddev

website-phishing/utils.js:104–111  ·  view source on GitHub ↗

* Calculate the standard deviation of a vector. * * @param {Array} vector The vector represented as an Array of Numbers. * * @returns {number} The standard deviation.

(vector)

Source from the content-addressed store, hash-verified

102 * @returns {number} The standard deviation.
103 */
104function stddev(vector) {
105 let squareSum = 0;
106 const vectorMean = mean(vector);
107 for (const x of vector) {
108 squareSum += (x - vectorMean) * (x - vectorMean);
109 }
110 return Math.sqrt(squareSum / (vector.length - 1));
111};
112
113/**
114 * Normalize a vector by its mean and standard deviation.

Callers 1

normalizeDatasetFunction · 0.70

Calls 1

meanFunction · 0.70

Tested by

no test coverage detected