diff --git a/.gitignore b/.gitignore index ca37570..d33caba 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ backup coverage coverage/* .venv +samples.txt diff --git a/cpp/Makefile b/cpp/Makefile index addb12a..a34a1b7 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -22,7 +22,7 @@ debug_build: test: build ./builddir/fuc2it -v -r_test: +r_test: test $(R_SCRIPT) tests/confirm.r run: build test diff --git a/cpp/include/stats.hpp b/cpp/include/stats.hpp index 82c4616..1aefc82 100644 --- a/cpp/include/stats.hpp +++ b/cpp/include/stats.hpp @@ -67,9 +67,6 @@ struct Stats { auto as_ms = std::chrono::duration_cast(elapsed); - fmt::println("sample time: {} vs. my calc: {}; as_ms: {}", - elapsed.count(), 1.0/elapsed.count(), as_ms.count()); - if(elapsed.count() > 0.0) { sample(1.0/elapsed.count()); } diff --git a/cpp/tests/confirm.r b/cpp/tests/confirm.r index 84e70a3..6547c64 100644 --- a/cpp/tests/confirm.r +++ b/cpp/tests/confirm.r @@ -1,7 +1,3 @@ -samples <- read.table("bad_samples.txt") -t.test(samples$V1, samples$V2) - - samples <- read.table("samples.txt") print(samples) t.test(samples$V1, samples$V2) diff --git a/cpp/tests/stats_tests.cpp b/cpp/tests/stats_tests.cpp index cbb5c05..c3ba65d 100644 --- a/cpp/tests/stats_tests.cpp +++ b/cpp/tests/stats_tests.cpp @@ -113,11 +113,20 @@ namespace stats_tests { welf2.sample(num + skew_factor); } - fmt::println("welford samples t-test:"); welf.t_test(welf2); - - fmt::println("naive algebra samples t-test:"); stats.t_test(stats2); + + auto stats_test = stats.t_test(stats2); + auto welf_test = welf.t_test(welf2); + + ALMOST_EQUAL(stats_test.t_stat, welf_test.t_stat, 5); + ALMOST_EQUAL(stats_test.dof, welf_test.dof, 1); + ALMOST_EQUAL(stats_test.p_val, welf_test.p_val, 5); + + fmt::println("welford samples t-test: t-val: {}, dof: {}, p-val: {}", + welf_test.t_stat, welf_test.dof, welf_test.p_val); + fmt::println("naive algebra samples t-test: t-val: {}, dof: {}, p-val: {}", + stats_test.t_stat, stats_test.dof, stats_test.p_val); } void failing_bad_t_test() {