private static double computeCrc(int[][] squares) {
		//calculate CR
		double numerator = 0;	//start by computing the numerator
		
		for (int row = 0; row < 4; row++) {				
			double pi = 0; //nb of dots in this row divided by total number of dots
			
			for (int col = 0; col < 4; col++) {
				pi += squares[row][col];
			}
			
			pi = pi / 4;
			
			if (pi != 0) {
				numerator += pi * log2(1/pi); //avoid division by zero; we assume that 0 * Log₂0 = 0			
			}
		}
		double cr = 1 - numerator / log2(4);
		
		//calculate CC
		numerator = 0;		
		for (int col = 0; col < 4; col++) {		
			double pi = 0; //nb of dots in this col divided by total number of dots
			
			for(int row = 0; row < 4; row++) {
				pi += squares[row][col]; 
			}
			
			pi = pi / 4;
			
			if (pi != 0) {
				numerator += pi * log2(1/pi); //avoid division by zero; we assume that 0 * Log₂0 = 0			
			}
		}		
		double cc = 1 - numerator / log2(4);
		
		return 1 - (( 1 - cr ) * ( 1 - cc)); //return CRC
	}