protected static Map < Double , Double > doQuantization ( double max , double min , double [ ] values ) { double range = max - min ; int noIntervals = 20 ; double intervalSize = range / noIntervals ; int [ ] intervals = new int [ noIntervals ] ; for ( double value : values ) { int interval = Math . min ( noIntervals - 1 , ( int ) Math . floor ( ( value - min ) / intervalSize ) ) ; assert interval >= 0 && interval < noIntervals : "Invalid interval: " + interval ; ++ intervals [ interval ] ; } Map < Double , Double > discretisedValues = new HashMap < Double , Double > ( ) ; for ( int i = 0 ; i < intervals . length ; i ++ ) { // Correct the value to take into account the size of the interval. double value = ( 1 / intervalSize ) * ( double ) intervals [ i ] ; discretisedValues . put ( min + ( ( i + 0.5 ) * intervalSize ) , value ) ; } return discretisedValues ; }
Convert the continuous values into discrete values by chopping up the distribution into several equally - sized intervals .