// Example from "Introduction to Probability and Statistics For Engineers and Scientists"
// by Sheldon M. Ross


#include <iostream.h>
#include "hyptest.h"

float teststat(Data<float> &testsamp,float testmean);

int main()
{
	cout << "It is known that if a signal of value m is send from location A, then the" << endl
		<< "value received at location B is normally distributed with a mean m and" << endl
		<< "variance 16.  Test the hypothesis that m=8 given that the same value is" << endl
		<< "independently sent 5 times and the values received at location B are 9.0," << endl
		<< "9.4, 9.5, 9.6, and 10.0." << endl << endl;
	cout << "> float a[5] = {9.0,9.4,9.5,9.6,10.0}" << endl
		<< "Storing sample of floats in the array a..." << endl << endl;	
	float a[5] = {9.0,9.4,9.5,9.6,10.0};
	cout << "> KnVarData<float> signal1(a,5,4)" << endl
		<< "Constructing an instance of the class KnVarData..." << endl << endl;
	KnVarData<float> signal1(a,5,4);
	cout << "> signal1.sampmean()" << endl
		<< "Calculating sample mean..." << endl
		<< signal1.sampmean() << endl << endl;
	cout << "> signal1.sampvar()" << endl
		<< "Calculating sample variance..." << endl
		<< signal1.sampvar() << endl << endl;
	cout << "> teststat(signal1,8)" << endl
		<< "Testing hypothesis of m = 8 - Calculating probability of Type I error..."<< endl
		<< teststat(signal1,8) << endl << endl;
	return 0;
}

float teststat(Data<float> &testsamp,float testmean)
{
	return testsamp.meantest(testmean);
}
