private void computeGridCountAndCentroids(HashMap<ArrayList<Integer>, Integer> data) {
		// create the number of grid for each dimension
		dimSize = new int[numDimension]; // the number of grids for each dimension
		for (int i=0; i<numDimension; i++) {
			int rangeDimension = maxList[i] - minList[i];
			dimSize[i] = rangeDimension / gridSize + 1;
		}
		
		
		// we can store gridCount inside Hashmap as:
		// key = [d1, d2, d3] --> arrayList
		// value = count --> the count of points in grid[d1,d2,d3] --> grid score		
		gridCount = new HashMap<ArrayList<Integer>,Integer>();   
		HashMap<ArrayList<Integer>,ArrayList<Integer>> gridSumPoints = new HashMap<ArrayList<Integer>,ArrayList<Integer>>();   

		// iterate over all elements of data
		for (Map.Entry<ArrayList<Integer>, Integer> entry : data.entrySet()) {
		    
			// get the elements of data  
			ArrayList<Integer> key = entry.getKey();
		    Integer value = entry.getValue();
		    
		    // find out the index of each key (or points)
		    ArrayList<Integer> gridIndexes = intToGridIndex(key); 

		    // put into gridCount
		    if ( gridCount.containsKey(gridIndexes) ) {
		    	// adding additional (number of) points
		    	int prevValue = gridCount.get(gridIndexes); 
		    	gridCount.put(gridIndexes, prevValue+value);
		    	
		    	ArrayList<Integer> prevSum = gridSumPoints.get(gridIndexes);
		    	gridSumPoints.put(gridIndexes,Util.additionArrayList(prevSum, Util.multiplicationArrayList(key, value)));
		    } else {
		    	
		    	// put the first number of points here
		    	gridCount.put(gridIndexes, value);
		    	
		    	// first sum of coordinate points 
		    	gridSumPoints.put(gridIndexes, Util.multiplicationArrayList(key,value));
		    }		    
		    
		}
		
		// finalize the grid centroids
		gridCentroids = new HashMap<ArrayList<Integer>, ArrayList<Double> > ();
		for (Map.Entry<ArrayList<Integer>, ArrayList<Integer>> entry : gridSumPoints.entrySet()) {
			ArrayList<Integer> key = entry.getKey();
			int count = gridCount.get(key); 
			ArrayList<Integer> initialCentroids = gridSumPoints.get(key);
			gridCentroids.put(key, Util.divisionArrayList(initialCentroids, count) );
		}
		
	}