repositories
/
e-mobility-charging-stations-simulator.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1d8f226
)
refactor: cleanup standard deviation implementation
author
Jérôme Benoit
<jerome.benoit@sap.com>
Fri, 15 Sep 2023 20:08:51 +0000
(22:08 +0200)
committer
Jérôme Benoit
<jerome.benoit@sap.com>
Fri, 15 Sep 2023 20:08:51 +0000
(22:08 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/StatisticUtils.ts
patch
|
blob
|
blame
|
history
diff --git
a/src/utils/StatisticUtils.ts
b/src/utils/StatisticUtils.ts
index ecd47a17f9af0b2d49601542ec3c8af78997d9dd..7f338ff9d08d88651a6d012b036ef73f43946ec5 100644
(file)
--- a/
src/utils/StatisticUtils.ts
+++ b/
src/utils/StatisticUtils.ts
@@
-68,9
+68,9
@@
export const stdDeviation = (
dataSet: number[],
dataSetAverage: number = average(dataSet),
): number => {
- const geometricDeviation = dataSet.reduce((accumulator, nb) => {
- const deviation = nb - dataSetAverage;
-
return accumulator + deviation * deviation
;
- }, 0);
-
return Math.sqrt(geometricDeviation / dataSet.length
);
+ return Math.sqrt(
+ dataSet.reduce((accumulator, num) => {
+
return accumulator + Math.pow(num - dataSetAverage, 2)
;
+ }, 0) / dataSet.length,
+ );
};