[libcxx-commits] [libcxx] [libc++] Adjust some of the [rand.dist] critical values that are too strict (PR #88669)

Matt Stephanson via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 15 14:21:13 PDT 2024


================
@@ -151,8 +151,8 @@ void test3() {
     double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
     assert(std::abs((mean - x_mean) / x_mean) < 0.01);
     assert(std::abs((var - x_var) / x_var) < 0.01);
-    assert(std::abs((skew - x_skew) / x_skew) < 0.03);
-    assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
----------------
MattStephanson wrote:

Oops, I was debating changing it to an absolute test because the expected kurtosis is close to zero (-0.017). 2.0 should be the relative bound.

For reference, if you approximate the binomial distribution as normal, you would expect the sample kurtosis to have a standard deviation of $\sqrt{24/N} \approx 0.0155$. That gives a relative 90% confidence interval of $\sqrt{2}\mathrm{erf}^{-1}(0.9)\cdot 0.0155 / 0.017 \approx 1.5$, so I don't think the empirically observed value of 2.0 is unreasonable.

https://github.com/llvm/llvm-project/pull/88669


More information about the libcxx-commits mailing list