openGPMP
Open Source Mathematics Package
hypo.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <openGPMP/stats/hypothesis.cpp>
3 
4 int main() {
5  // Example usage of the extended HypothesisTest class
6  std::vector<double> sample1 = {25, 30, 28, 32, 35};
7  std::vector<double> sample2 = {20, 22, 18, 24, 21};
8  std::vector<std::vector<double>> samples = {{10, 12, 14},
9  {15, 17, 19},
10  {20, 22, 24}};
11  std::vector<std::vector<int>> observed = {{10, 20, 30},
12  {15, 25, 35},
13  {25, 35, 45}};
14  std::vector<std::vector<double>> expected = {{15, 25, 35},
15  {20, 30, 40},
16  {30, 40, 50}};
17 
18  std::cout << "One-sample t-test: "
20  << std::endl;
21  std::cout << "Two-sample t-test: "
23  << std::endl;
24  std::cout << "ANOVA: " << gpmp::stats::HypothesisTest::ANOVA(samples)
25  << std::endl;
26  std::cout << "Chi-square test: "
28  expected)
29  << std::endl;
30  std::cout << "Z-test for proportions: "
32  0.4,
33  100,
34  100)
35  << std::endl;
36  std::cout << "Wilcoxon signed-rank test: "
38  sample2)
39  << std::endl;
40  std::cout << "Mann-Whitney U test: "
42  sample2)
43  << std::endl;
44 
45  return 0;
46 }
static double mann_whitney_test(const std::vector< double > &sample1, const std::vector< double > &sample2)
Mann-Whitney U test.
Definition: hypothesis.cpp:177
static double two_sample_ttest(const std::vector< double > &sample1, const std::vector< double > &sample2)
Two-sample t-test.
Definition: hypothesis.cpp:52
static double chi_square_test(const std::vector< std::vector< int >> &observed, const std::vector< std::vector< double >> &expected)
Chi-square test of independence.
Definition: hypothesis.cpp:107
static double ANOVA(const std::vector< std::vector< double >> &samples)
Analysis of Variance (ANOVA)
Definition: hypothesis.cpp:69
static double one_sample_ttest(const std::vector< double > &sample, double populationMean)
One-sample t-test.
Definition: hypothesis.cpp:42
static double proportion_z_test(double p1, double p2, double n1, double n2)
Z-test for proportions.
Definition: hypothesis.cpp:125
static double wilcoxon_rank_test(const std::vector< double > &sample1, const std::vector< double > &sample2)
Wilcoxon signed-rank test.
Definition: hypothesis.cpp:135
int main()
Definition: hypo.cpp:4