[libcxx-commits] [PATCH] D114920: [libc++] Re-enable `uniform_int_distribution<bool>`.

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 1 17:12:10 PST 2021


jloser added inline comments.


================
Comment at: libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp:84-91
+    assert(std::abs(mean - expected_mean) < range / 100);
+    assert(std::abs(var - expected_var) < expected_var / 50);
+    assert(-0.1 < skew && skew < 0.1);
+    if (a + 1 == b) {
+        assert(0.9 < kurtosis && kurtosis < 1.1);
+    } else {
+        assert(1.6 < kurtosis && kurtosis < 2.0);
----------------
Quuxplusone wrote:
> Before you ask: yeah, these error bounds are crazy ad-hoc. But:
> - the test isn't "flaky": in the sense that the engine `g` will always produce the same random sequence, so our code for `dist` should always cook that sequence into something that satisfies these arbitrary error bounds, and if it ever changes so that the error bounds fail, then we can just go edit this test.
> - the old test was way more ad-hoc: like, what even is `std::abs((mean - x_mean) / x_mean) < 0.01`? Dividing by the mean of the distribution? We're just lucky they never tried a distribution with a mean of zero. 😀
One of those "oh boy" moments when looking at the existing trunk code (e.g. mean of zero comment).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114920/new/

https://reviews.llvm.org/D114920



More information about the libcxx-commits mailing list