openGPMP
Open Source Mathematics Package
hypothesis.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  *
3  * Project
4  * _____ _____ __ __ _____
5  * / ____| __ \| \/ | __ \
6  * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7  * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8  *| (_) | |_) | __/ | | | |__| | | | | | | |
9  * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10  * | |
11  * |_|
12  *
13  * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14  *
15  * This software is licensed as described in the file LICENSE, which
16  * you should have received as part of this distribution. The terms
17  * among other details are referenced in the official documentation
18  * seen here : https://akielaries.github.io/openGPMP/ along with
19  * important files seen in this project.
20  *
21  * You may opt to use, copy, modify, merge, publish, distribute
22  * and/or sell copies of the Software, and permit persons to whom
23  * the Software is furnished to do so, under the terms of the
24  * LICENSE file.
25  *
26  *
27  *
28  * This software is distributed on an AS IS basis, WITHOUT
29  * WARRANTY OF ANY KIND, either express or implied.
30  *
31  ************************************************************************/
32 #ifndef HYPOTHESIS_HPP
33 #define HYPOTHESIS_HPP
34 
35 #include <algorithm>
36 #include <cmath>
37 #include <vector>
38 
39 namespace gpmp {
40 
41 namespace stats {
42 
48  public:
53  }
54 
59  }
60 
67  static double one_sample_ttest(const std::vector<double> &sample,
68  double populationMean);
69 
76  static double two_sample_ttest(const std::vector<double> &sample1,
77  const std::vector<double> &sample2);
78 
84  static double ANOVA(const std::vector<std::vector<double>> &samples);
85 
92  static double
93  chi_square_test(const std::vector<std::vector<int>> &observed,
94  const std::vector<std::vector<double>> &expected);
95 
104  static double proportion_z_test(double p1, double p2, double n1, double n2);
105 
112  static double wilcoxon_rank_test(const std::vector<double> &sample1,
113  const std::vector<double> &sample2);
114 
121  static double mann_whitney_test(const std::vector<double> &sample1,
122  const std::vector<double> &sample2);
123 
129  static double fisher_test(const std::vector<std::vector<int>> &table);
130 
137  static double kol_smirnov_test(const std::vector<double> &sample1,
138  const std::vector<double> &sample2);
139 
146  static double wilcoxon_rank_sum_test(const std::vector<double> &sample1,
147  const std::vector<double> &sample2);
148 
154  static double
155  kruskal_wallis_test(const std::vector<std::vector<double>> &samples);
156 
162  static double runs_test(const std::vector<bool> &sequence);
163 
164  private:
170  static int factorial(int n);
171 };
172 } // namespace stats
173 
174 } // namespace gpmp
175 
176 #endif
A class for conducting various statistical hypothesis tests.
Definition: hypothesis.hpp:47
static int factorial(int n)
Helper method to calculate factorial.
Definition: hypothesis.cpp:342
static double fisher_test(const std::vector< std::vector< int >> &table)
Fisher's Exact Test.
Definition: hypothesis.cpp:199
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 runs_test(const std::vector< bool > &sequence)
Runs Test.
Definition: hypothesis.cpp:324
static double kol_smirnov_test(const std::vector< double > &sample1, const std::vector< double > &sample2)
Kolmogorov-Smirnov Test.
Definition: hypothesis.cpp:224
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
HypothesisTest()
Constructor.
Definition: hypothesis.hpp:52
static double kruskal_wallis_test(const std::vector< std::vector< double >> &samples)
Kruskal-Wallis Test.
Definition: hypothesis.cpp:282
static double wilcoxon_rank_test(const std::vector< double > &sample1, const std::vector< double > &sample2)
Wilcoxon signed-rank test.
Definition: hypothesis.cpp:135
static double wilcoxon_rank_sum_test(const std::vector< double > &sample1, const std::vector< double > &sample2)
Wilcoxon Rank Sum Test (Mann-Whitney U Test)
Definition: hypothesis.cpp:251
The source C++ openGPMP namespace.