public double computeSimilarity(int user1, int user2) {

		double sim = 0;

		// generate arrays containing ratings from users which rated both movies
		List<Integer> sharedMovies = findSharedMovies(user1, user2);
		if (sharedMovies.isEmpty()) {
			return sim;
		}

		Double[] userOneRatings = new Double[sharedMovies.size()];
		Double[] userTwoRatings = new Double[sharedMovies.size()];

		for (int i = 0; i < sharedMovies.size(); i++) {
			userOneRatings[i] = userMovieRatings.get(user1).get(sharedMovies.get(i));
			userTwoRatings[i] = userMovieRatings.get(user2).get(sharedMovies.get(i));
		}

		// Calculate the similarity using the defined metric
		if (sMetric.toLowerCase().equals("cosinesimilarity")) {
			sim = Similarity.calculateCosineSimilarity(userOneRatings, userTwoRatings);
		} else if (sMetric.toLowerCase().equals("pearsoncorrelation")) {
			sim = Similarity.calculatePearsonCorrelation(userOneRatings, userTwoRatings, averageRatings.get(user1),
					averageRatings.get(user2));
		}
		return sim;
	}