diff options
| author | Tom Harley | 2019-01-27 15:37:06 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-01-27 15:37:06 +0000 |
| commit | a996283af7c21baaff0e114d58c34db820902c6f (patch) | |
| tree | 2fe5b6f7a800d4a7b8a65ee345f8c98aa138e36b /src/main/evaluation/binomial_ci.cpp | |
| parent | Split code into 3 files (diff) | |
| download | metasol-a996283af7c21baaff0e114d58c34db820902c6f.tar.gz metasol-a996283af7c21baaff0e114d58c34db820902c6f.zip | |
Reorganise repo
All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily.
There’s also a lot of other work done here, such as usign a thread pool library to manage the running of the voters.
Diffstat (limited to 'src/main/evaluation/binomial_ci.cpp')
| -rw-r--r-- | src/main/evaluation/binomial_ci.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/main/evaluation/binomial_ci.cpp b/src/main/evaluation/binomial_ci.cpp deleted file mode 100644 index c381c05..0000000 --- a/src/main/evaluation/binomial_ci.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// Created by thecharlesblake on 20/06/18. -// - -#include <cmath> -#include <algorithm> -#include "binomial_ci.h" - -using std::pow; -using std::min; -using std::max; -using std::pair; - -pair<double, double> binomial_ci::wilson(int s_, int f_) { - auto s = static_cast<double>(s_); - auto f = static_cast<double>(f_); - double z = 1.96; - double z2 = pow(z, 2); - double n = s + f; - double p = (s + (z2 / 2.0)) / (n + z2); - double half_ci = (z / (n + z2)) * sqrt(((s * f) / n) + (z2 / 4.0)); - return { p - half_ci - , p + half_ci }; -} - -pair<double, double> binomial_ci::wilson(int s, int f, int i) { - pair<double, double> a = wilson(s, f + i); - pair<double, double> b = wilson(s + i, f); - return {a.first, b.second}; -} - -pair<double, double> binomial_ci::agresti_coull(int s, int f) { - double z = 1.96; - double n_ = s + f + pow(z, 2); - double p = (s + pow(z, 2)/2)/n_; - double half_ci = z * sqrt((p - pow(p, 2))/n_); - return { max(0.0, p - half_ci) - , min(1.0, p + half_ci) }; -} - -pair<double, double> binomial_ci::agresti_coull(int s, int f, int i) { - pair<double, double> a = agresti_coull(s, f + i); - pair<double, double> b = agresti_coull(s + i, f); - return {a.first, b.second}; -} |
