X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2FPerformanceStatistics.ts;h=ecd6b3ab72a8cbf5b2e31865d4e18fc5d91c5131;hb=7436ee0df05bb41f3ce8a553adf5d9ed8da78903;hp=b2333fded5f80ce1eba0c2638b08cb8ed8908ae2;hpb=8f953431be60a5520dba937dd2cbd394a72af25d;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index b2333fde..ecd6b3ab 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -190,8 +190,8 @@ export class PerformanceStatistics { } const sortedDataSet = dataSet.slice().sort((a, b) => a - b); const middleIndex = Math.floor(sortedDataSet.length / 2); - if (sortedDataSet.length % 2) { - return sortedDataSet[middleIndex / 2]; + if (sortedDataSet.length % 2 === 0) { + return sortedDataSet[middleIndex]; } return (sortedDataSet[middleIndex - 1] + sortedDataSet[middleIndex]) / 2; } @@ -215,7 +215,7 @@ export class PerformanceStatistics { if (Number.isInteger(percentileIndex)) { return (sortedDataSet[percentileIndex] + sortedDataSet[percentileIndex + 1]) / 2; } - return sortedDataSet[Math.round(percentileIndex)]; + return sortedDataSet[Math.floor(percentileIndex)]; } private stdDeviation(dataSet: number[]): number {