private static void writeMetrics(String sampleDir, String sampleName,
			String prefix, int sampleCount, int k, String posfix) {
		String topicString = ((posfix == null || posfix == "0") ? "" : "_"
				+ posfix);
		for (int i = 1; i <= k; i++) {
			for (int j = 1; j <= sampleCount; j++) {
				MetricsCalculator.calculateMetrics(sampleName
						+ topicString + "_" + prefix, i, sampleDir + "/"
						+ prefix + topicString + "_metrics", false, null, null, null, null, null, true);
			}
			MetricsCalculator.writeAverageMetrics(sampleDir + "/" + prefix
					+ topicString + "_metrics", i, (double) sampleCount, true, i == k);
		}
		MetricsCalculator.resetMetrics();
	}