ProbabilityDistributions { static public Double calculateLabelCost(String calcLabel, Map<String, Double> labelProbabilities, CostMatrix<String> costMatrix) { if (calcLabel == null) { return Double.NaN; } double sum = 0.; for (String label: costMatrix.getKnownValues()) { double cost = costMatrix.getCost(label, calcLabel); double prob = labelProbabilities.get(label); sum += cost * prob; } return sum; }  static Double calculateLabelCost(String calcLabel,
			Map<String, Double> labelProbabilities, CostMatrix<String> costMatrix); static Map<T, Double> generateConstantDistribution(
		Collection<T> objects, double value); static Map<T, Double> generateUniformDistribution(
		Collection<T> objects); static Map<T, Double> generateUniformDistribution(
		Collection<T> objects, Map<T, Double> initialDistribution); static Map<String, Double> generateGoldDistribution(Collection<String> categories, String correctCat);  }
@Test public void testCalculateLabelCost() { String calcLabel = "OK"; Map<String, Double> labelProbabilities = new HashMap<String, Double>(); labelProbabilities.put("OK", 0.5); labelProbabilities.put("LOK", 0.0); labelProbabilities.put("HOK", 1.); CostMatrix<String> costMatrix = new CostMatrix<String>(); costMatrix.add("OK", "OK", 1.); costMatrix.add("LOK", "OK", 10.); costMatrix.add("HOK", "OK", 20.); Double result = ProbabilityDistributions.calculateLabelCost(calcLabel, labelProbabilities, costMatrix); assertEquals(20.5, result, 0.0); }