'Get consistency on scale from 0 to 100 from standard deviation js
As the title says I want to convert standard deviation to consistency on a scale from 0 to 100 but I'm unsure of how to accomplish this. So far I have a function to calculate the standard deviation but I don't know where to continue.
JS:
function standardDeviation(numArray) {
const mean = numArray.reduce((s, n) => s + n) / numArray.length;
const variance = numArray.reduce((s, n) => s + (n - mean) ** 2, 0) / (numArray.length - 1);
return Math.sqrt(variance);
}
an example of the data would be like: [1, 0.7193590816692575, 0.5724022479971302, 0.717924189884013, 0.8615329427239031, 0.7186416357766352, 0, 0.2863804854717206, 0.5745545856749971]
output would be the consistency of these numbers perhaps something like 70%
if the input data was [1, 1, 1, 1, 1, 1] the consistency would be 100%
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
