@Test public void testUnitScale_binary() { val data = new double[] { 4.0, 6.5 }; val scaled = DataUtil.unitScale(data); assertArrayEquals(new double[] { 0.0, 1.0 }, scaled, TOLERANCE); }
public static double[] unitScale(double[] data) { val summaryStats = Arrays.stream(data).summaryStatistics(); val min = summaryStats.getMin(); val max = summaryStats.getMax(); val range = max - min; val denom = (range == 0.0 ? 1.0 : range); return Arrays.stream(data) .map(value -> (value - min) / denom) .toArray(); }
DataUtil { public static double[] unitScale(double[] data) { val summaryStats = Arrays.stream(data).summaryStatistics(); val min = summaryStats.getMin(); val max = summaryStats.getMax(); val range = max - min; val denom = (range == 0.0 ? 1.0 : range); return Arrays.stream(data) .map(value -> (value - min) / denom) .toArray(); } }
DataUtil { public static double[] unitScale(double[] data) { val summaryStats = Arrays.stream(data).summaryStatistics(); val min = summaryStats.getMin(); val max = summaryStats.getMax(); val range = max - min; val denom = (range == 0.0 ? 1.0 : range); return Arrays.stream(data) .map(value -> (value - min) / denom) .toArray(); }  }
DataUtil { public static double[] unitScale(double[] data) { val summaryStats = Arrays.stream(data).summaryStatistics(); val min = summaryStats.getMin(); val max = summaryStats.getMax(); val range = max - min; val denom = (range == 0.0 ? 1.0 : range); return Arrays.stream(data) .map(value -> (value - min) / denom) .toArray(); }  static double[] unitScale(double[] data); }
DataUtil { public static double[] unitScale(double[] data) { val summaryStats = Arrays.stream(data).summaryStatistics(); val min = summaryStats.getMin(); val max = summaryStats.getMax(); val range = max - min; val denom = (range == 0.0 ? 1.0 : range); return Arrays.stream(data) .map(value -> (value - min) / denom) .toArray(); }  static double[] unitScale(double[] data);  }