(vector)
| 83 | // Returns: |
| 84 | // The standard deviation. |
| 85 | function stddev(vector) { |
| 86 | let squareSum = 0; |
| 87 | const vectorMean = mean(vector); |
| 88 | for (const x of vector) { |
| 89 | squareSum += (x - vectorMean) * (x - vectorMean); |
| 90 | } |
| 91 | return Math.sqrt(squareSum / (vector.length - 1)); |
| 92 | } |
| 93 | |
| 94 | // Normalize a vector by its mean and standard deviation. |
| 95 | function normalizeVector(vector, vectorMean, vectorStddev) { |
no test coverage detected