class 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();
    }

}