Sunteți pe pagina 1din 3

#include <boost/math/distributions/normal.hpp> // for normal_distribution using boost::math::normal; // typedef provides default type is double.

#include <iostream> using std::cout; using std::endl; using std::left; using std::showpoint; usi ng std::noshowpoint; #include <iomanip> using std::setw; using std::setprecision; #include <limits> using std::numeric_limits; #include<istream> // for details visit - www.quantfinanceindia.blogspot.com using namespace std; int main() { int mean,std,pvalue; int testchoice,conf; int z=0; cout << "\n\n\n Hypothesis Testing - Using Normal Distribution"; try { { int precision = 17; // traditional tabl es are only computed to much lower precision. normal s; // (default mean = zero, and standard deviation = unity) cout.precision(5); cout.precision(6); // default cout <<"\n Enter the mean value of the Sample"<<endl; cin>>mean; cout << "\n Enter Std Deviation for Sam ple"<<endl; cin>>std; z=0; z = mean/std; cout<<" \n Please use the following men u to Enter the hypothesis you want to test"<<endl; cout<<"\n 1. to validate if popul ation mean is equal to sample mean" "\n 2. to test if populat ion mean is less than sample mean" "\n 3. to find if populat ion mean is more than sample mean"<<endl; cin>>testchoice; cout<<" Enter the confidence interval y ou want to test for"<<endl; cout<< "\n 1. for 90% confidence interval" "\n 2. for 95% confidence inter val"

"\n 3. for 99% confidence inter val"<<endl; cin>>conf; if( testchoice == 1 && conf ==1 ) { if (pvalue < .05 or pvalue > . 95) cout <<" \n Null Hypot hesis not rejected as there is not enough statistical evidence"; else cout<<"\n Null Hypothe sis rejected and Alternative Hypothesis accepted"; } else if( testchoice == 1 && conf ==2 ) { if (pvalue < .10) cout <<" \n Null Hypothesis n ot rejected as there is not enough statistical evidence"; else cout<<"\n Null Hypothesis rej ected and Alternative Hypothesis accepted"; } else if( testchoice == 1 && conf ==3 ) { if (pvalue > .90) cout <<" \n Null Hypothesis n ot rejected as there is not enough statistical evidence"; else cout<<"\n Null Hypothesis rej ected and Alternative Hypothesis accepted"; } if( testchoice == 2 && conf ==1 ) { if (pvalue < .025 or pvalue > .9 75) cout <<" \n Null Hypothesis not rejected as there is not enough statistical evidence"; else cout<<"\n Null Hypothesis reject ed 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 rejec ted 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 rejec ted 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 rejec ted 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 rejec ted 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 rejec ted and Alternative Hypothesis accepted"; } cout<<endl; } } catch(const std::exception& e) { std::cout << "\n""Message from thrown exception was:\n return 0; } " << e.what() << std::endl; }

S-ar putea să vă placă și