/**
 * \brief Executes a two sample T test for the "Planning" example on the exercise sheet.
 */
void StatisticalTesting::planning() {
	const double confidenceLevel = 0.95;

	const double myPlanner[] = {
		  90, 104, 142, 143, 121,
		 190,  92,  93, 166, 110,
		 191, 122, 129, 176, 110,
		  45,  78, 166, 173, 115,
		 197,  63, 156, 124,  98
	};
	const double baselinePlanner[] = {
		 56,  92, 145, 117, 121,
		 91, 147, 174, 122, 111,
		143, 142, 189, 129,  92,
		112, 122, 120, 125, 200,
		137, 147, 89, 101, 108
	};

	TestCase test;
	Hypothesis a("My planner produces longer paths than the baseline.", GREATER);
	Hypothesis b("My planner produces shorter paths than the baseline.", LESS);
	Hypothesis c("My plans are at most as long as the baseline plans.", AT_MOST);
	Hypothesis d("My plans are at least as long as the baseline plans.", AT_LEAST);
	Hypothesis e("My plans are as long as the baseline paths.", EQUAL);
	Hypothesis f("My plans have different lengths than the baseline paths.", DIFFERENT);

	test.setHypothesis(f);
	test.setNullHypothesis(e);
	twoSampleTTest(arrayToVector(myPlanner), arrayToVector(baselinePlanner),
			confidenceLevel, test);
}
/**
 * \brief Executes a Z test for the "German students test" example on the slides.
 */
void StatisticalTesting::germanStudentsTest() {
	const double testResults[] = {
			97, 77, 100, 99, 100, 75, 76, 95, 96, 90,
			96, 70, 71, 98, 97, 97, 67, 100, 97, 100,
			92, 130, 100, 100, 95, 100, 92, 94, 89,
			89, 82, 65, 100, 98, 85, 100, 93, 87, 100,
			97, 73, 100, 93, 110, 95, 110, 79, 92, 96,
			100, 87, 92, 110, 110, 100
	};
	const double distributionMean = 100;
	const double distributionStandardDeviation = 12;
	const double confidenceLevel = 0.95;

	TestCase test;
	Hypothesis a("Bonn students are better than other students", GREATER);
	Hypothesis b("Bonn students are worse than other students", LESS);
	Hypothesis c("Bonn students are at least as good as other students", AT_LEAST);
	Hypothesis d("Bonn students are at most as good as other students", AT_MOST);
	Hypothesis e("Bonn students are as good as other students", EQUAL);
	Hypothesis f("Bonn students perform differently from other students", DIFFERENT);

	/* TODO: Select a hypothesis and a null hypothesis from the above choices a-f and
	 * call test.setHypothesis(...) and test.setNullHypothesis(...) with the chosen
	 * variable.
	 */
    test.setHypothesis(b);
    test.setNullHypothesis(c);

	oneSampleZTest(arrayToVector(testResults), distributionMean, distributionStandardDeviation, confidenceLevel, test);
}
/**
 * \brief Executes a one sample T test for the "Cars" example on the slides.
 */
void StatisticalTesting::cars() {
	const double prices[] = {11492.70, 23848.70, 15096.80, 27376.10, 15576.50};
	const double distributionMean = 12000;
	const double confidenceLevel = 0.95;

	TestCase test;
	Hypothesis a("The cars are more expensive than in the rest of the city", GREATER);
	Hypothesis b("The cars are cheaper than in the rest of the city", LESS);
	Hypothesis c("The cars are at least as expensive as in the rest of the city", AT_LEAST);
	Hypothesis d("The cars are at most as expensive as in the rest of the city", AT_MOST);
	Hypothesis e("The cars are as expensive as in the rest of the city", EQUAL);
	Hypothesis f("The prices of the cars are different from the rest of the city", DIFFERENT);

	/* TODO: Select a hypothesis and a null hypothesis from the above choices a-f and
	 * call test.setHypothesis(...) and test.setNullHypothesis(...) with the chosen
	 * variable.
	 */
	 test.setHypothesis(a);
	 test.setNullHypothesis(d);

	oneSampleTTest(arrayToVector(prices), distributionMean, confidenceLevel, test);
}