public static double calculatePearsonCorrelation(Double[] vectorOne, Double[] vectorTwo, double averageOne,
			double averageTwo) {

		double enumerator = 0, denominatorOne = 0, denominatorTwo = 0;

		for (int i = 0; i < vectorOne.length; i++) {
			enumerator += (vectorOne[i] - averageOne) * (vectorTwo[i] - averageTwo);
			denominatorOne += Math.pow(vectorOne[i] - averageOne, 2);
			denominatorTwo += Math.pow(vectorTwo[i] - averageTwo, 2);
		}

		if (enumerator == 0 || denominatorOne == 0 || denominatorTwo == 0) {
			return 0;
		} else {
			return enumerator / Math.sqrt(denominatorOne * denominatorTwo);
		}
	}