From 25159009caae2c6b0d1f75956d370167a2925646 Mon Sep 17 00:00:00 2001 From: jlizier Date: Thu, 9 Jun 2022 12:39:59 +1000 Subject: [PATCH] updating max entropy discretisation to gracefully handle NaNs in the input (which shouldn't be there anyway) --- java/source/infodynamics/utils/MatrixUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/source/infodynamics/utils/MatrixUtils.java b/java/source/infodynamics/utils/MatrixUtils.java index 5b14833..d02f263 100755 --- a/java/source/infodynamics/utils/MatrixUtils.java +++ b/java/source/infodynamics/utils/MatrixUtils.java @@ -4866,9 +4866,16 @@ public class MatrixUtils { compartmentSize = (int)((double)(i+1)*(double)(data.length)/(double)numBins)-1; // System.out.println(compartmentSize); cutOffValues[i]=tempData[compartmentSize]; + // If there are NaNs in the data (which there shouldn't be, they get sorted into the max positions. + // Deal with this by assigning the max actual data value to the first bin that encounters this + // (if there are others, they won't get any points. User should not be supplying NaNs anyway. + if (Double.isNaN(cutOffValues[i])) { + cutOffValues[i] = MatrixUtils.max(data); + } } - for (int i=0;i