From 776134bdccf09b79f156e37e46c8f820ee57a61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Thu, 3 Oct 2019 09:56:53 +0200 Subject: [PATCH] Remove NaN for stats to have a result when some values is missing --- content/multipledataset.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/multipledataset.html b/content/multipledataset.html index 564116de..4518dbb5 100644 --- a/content/multipledataset.html +++ b/content/multipledataset.html @@ -129,9 +129,9 @@ draft: false } row.appendChild(td) } - - const avals=vals.map(v=>Math.abs(v)) - for(const val of [ss.min(vals),ss.max(vals),ss.mean(vals),ss.mean(avals),ss.median(vals),ss.median(avals),ss.rootMeanSquare(vals),ss.variance(vals),ss.standardDeviation(vals)]){ + const noNanVals=vals.filter((v)=>!Number.isNaN(v)) + const avals=noNanVals.map(v=>Math.abs(v)) + for(const val of [ss.min(noNanVals),ss.max(noNanVals),ss.mean(noNanVals),ss.mean(avals),ss.median(noNanVals),ss.median(avals),ss.rootMeanSquare(noNanVals),ss.variance(noNanVals),ss.standardDeviation(noNanVals)]){ var td=document.createElement("td") td.innerText=noNanPrecision(val,3) row.appendChild(td)