"\n 3. for 99% confidence interval"<
cin>>conf;
if( testchoice == 1 && conf ==1 )
{
if (pvalue < .05 or pvalue > .95)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 1 && conf ==2 )
{
if (pvalue < .10)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 1 && conf ==3 )
{ if (pvalue > .90)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
if( testchoice == 2 && conf ==1 )
{
if (pvalue < .025 or pvalue > .975)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 2 && conf ==2 )
{
if (pvalue < .05 )
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 2 && conf ==3 )
{
if(pvalue > .95 )
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
if( testchoice == 3 && conf ==1 )
{
if (pvalue < .005 or pvalue > .995)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 3 && conf ==2 )
{
if (pvalue < .01)
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
else if( testchoice == 3 && conf ==3 )
{
if (pvalue > .01 )
cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence";
else
cout<<"\n Null Hypothesis rejected and Alternative Hypothesis accepted";
}
cout<
}
}
catch(const std::exception& e)
{
std::cout <<
"\n""Message from thrown exception was:\n " << e.what() << std::endl;
}
return 0;
}
Boost
It is c++ library for the implementation of many utilities, we will be utilizing mathematical distribution library for calculation of p value. Installation of boos can be done following below steps -
2. unzip the file in /usr/include/ directort using cp or tar commands
3. Go inside the folder and run ./bootstrap.sh
4. /b2 install
working of the code
1. Code will ask you the mean of the sample you want to use and then the standard deviation of the sample
2. Next ask will be the test you want to conduct, are you looking of one tail or two tail test (equality of the mean or less than or greater than relation)
3. Confidence interval you want to choose
4. Result will shown as if Null Hypothesis is accepted or not and what is the result.
Code is stored [at] -
Output of the c++ code for hypothesis testing is
Hypothesis Testing - Using Normal Distribution
Enter the mean value of the Sample
3
Enter Std Deviation for Sample
3
Please use the following menu to Enter the hypothesis you want to test
1. to validate if population mean is equal to sample mean
2. to test if population mean is less than sample mean
3. to find if population mean is more than sample mean
1
Enter the confidence interval you want to test for
1. for 90% confidence interval
2. for 95% confidence interval
3. for 99% confidence interval
1
Null Hypothesis not rejected as there is not enough statistical evidence