public static double [ ] range2Bins ( double min , double max , double step , boolean doLastEqual ) { double intervalsDouble = ( max - min ) / step ; int intervals = ( int ) intervalsDouble ; double rest = intervalsDouble - intervals ; if ( rest > D_TOLERANCE ) { intervals ++ ; } double [ ] bins = new double [ intervals + 1 ] ; int count = 0 ; double running = min ; for ( int i = 0 ; i < intervals ; i ++ ) { bins [ count ] = running ; running = running + step ; count ++ ; } if ( doLastEqual ) { bins [ intervals ] = running ; } else { bins [ intervals ] = max ; } return bins ; }
Creates an array of bins from a range and a step to use .