public static double calculateChiSquare(Model model, String featureA, String featureB, String splitChar) {
		if (model.getFeatureValueFrequency().get(featureA + splitChar + featureB) == null) {
			System.out.println("feature key \"" + featureA + splitChar + featureB + "\" not found in model. wrong order of feature keys?");
			return 0.0;
		} else {
			double all = model.getFeatureValueFrequency().get("all").get("all");
			double p = 0;
			double expected;
			double real;
			for (Map.Entry<String, Integer> fA : model.getFeatureValueFrequency().get(featureA).getMap().entrySet()) {
				for (Map.Entry<String, Integer> fB : model.getFeatureValueFrequency().get(featureB).getMap().entrySet()) {
					expected = (fA.getValue() / all) * fB.getValue();
					real = model.getFeatureValueFrequency().get(featureA + splitChar + featureB).get(fA.getKey() + splitChar + fB.getKey());
					if (real < 0)
						System.out.println("ERROR real: " + real);
					if (fA.getValue() < 0)
						System.out.println("ERROR fA: " + fA.getValue());
					if (fB.getValue() < 0)
						System.out.println("ERROR fB: " + fB.getValue());
					if (expected < 0)
						System.out.println("ERROR fA: " + fA.getValue() + "; fB: " + fB.getValue() + " => " + (fA.getValue() * fB.getValue()) + " => " + expected);
					p += (real - expected) * (real - expected) / expected;
				}
			}
			return p;
		}
	}