aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-09 11:56:26 -0500
committerJack Lloyd <[email protected]>2018-12-09 11:56:26 -0500
commit72301413035187a998f6c19530aa884222dc8023 (patch)
tree3647efecc8e2414973e7b42de24ea0a359b0dec7 /src
parent537b94953a5ffc490d7f656dff347ef3fc795663 (diff)
Remove Chi-square test on random_integer
I'm not sure this test is that useful, which is not itself a big problem, but it is also flaky and occasionally fails, which is no good.
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_bigint.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp
index d85115e03..d0b533aea 100644
--- a/src/tests/test_bigint.cpp
+++ b/src/tests/test_bigint.cpp
@@ -33,7 +33,6 @@ class BigInt_Unit_Tests final : public Test
std::vector<Test::Result> results;
results.push_back(test_bigint_sizes());
- results.push_back(test_random_integer());
results.push_back(test_random_prime());
results.push_back(test_encode());
results.push_back(test_bigint_io());
@@ -137,51 +136,6 @@ class BigInt_Unit_Tests final : public Test
return result;
}
- Test::Result test_random_integer()
- {
- Test::Result result("BigInt::random_integer");
-
- result.start_timer();
-
- const size_t SAMPLES = 500000;
-
- const uint64_t range_min = 0;
- const uint64_t range_max = 100;
-
- /*
- * We have a range of 0...100 thus 100 degrees of freedom.
- * This bound is 99.9% probability of non-uniform
- */
- const double CHI_CRIT = 148.230;
-
- std::map<uint32_t, size_t> counts;
-
- for(size_t i = 0; i != SAMPLES; ++i)
- {
- uint32_t r = BigInt::random_integer(Test::rng(), range_min, range_max).to_u32bit();
- counts[r] += 1;
- }
-
- // Chi-square test
- const double expected = static_cast<double>(SAMPLES) / (range_max - range_min);
- double chi2 = 0;
-
- for(auto sample : counts)
- {
- const double count = static_cast<double>(sample.second);
- chi2 += ((count - expected)*(count - expected)) / expected;
- }
-
- if(chi2 >= CHI_CRIT)
- result.test_failure("Failed Chi-square test, value " + std::to_string(chi2));
- else
- result.test_success("Passed Chi-square test, value " + std::to_string(chi2));
-
- result.end_timer();
-
- return result;
- }
-
Test::Result test_encode()
{
Test::Result result("BigInt encoding functions");