public double computeSimilarity(int movie1, int movie2) {

		double sim = 0;

		// generate arrays containing ratings from users which rated both movies
		List<Integer> sharedUsers = findSharedUsers(movie1, movie2);
		if (sharedUsers.isEmpty()) {
			return sim;
		}

		Double[] movieOneRatings = new Double[sharedUsers.size()];
		Double[] movieTwoRatings = new Double[sharedUsers.size()];

		for (int i = 0; i < sharedUsers.size(); i++) {
			movieOneRatings[i] = userMovieRatings.get(sharedUsers.get(i)).get(movie1);
			movieTwoRatings[i] = userMovieRatings.get(sharedUsers.get(i)).get(movie2);
		}

		// Calculate the similarity using the defined metric
		if (sMetric.toLowerCase().equals("cosinesimilarity")) {
			sim = Similarity.calculateCosineSimilarity(movieOneRatings, movieTwoRatings);
		} else if (sMetric.toLowerCase().equals("pearsoncorrelation")) {
			sim = Similarity.calculatePearsonCorrelation(movieOneRatings, movieTwoRatings, averageRatings.get(movie1),
					averageRatings.get(movie2));
		}
		return sim;
	}