Function outlier_variance

Synopsis

#include <include/internal/benchmark/detail/catch_stats.hpp>

double outlier_variance(Estimate< double > mean, Estimate< double > stddev, int n)

Description

No description yet.

Source

Lines 151-175 in include/internal/benchmark/detail/catch_stats.cpp. Line 147 in include/internal/benchmark/detail/catch_stats.hpp.

double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n) {
    double sb = stddev.point;
    double mn = mean.point / n;
    double mg_min = mn / 2.;
    double sg = std::min(mg_min / 4., sb / std::sqrt(n));
    double sg2 = sg * sg;
    double sb2 = sb * sb;
    auto c_max = [n, mn, sb2, sg2](double x) -> double {
        double k = mn - x;
        double d = k * k;
        double nd = n * d;
        double k0 = -n * nd;
        double k1 = sb2 - n * sg2 + nd;
        double det = k1 * k1 - 4 * sg2 * k0;
        return (int)(-2. * k0 / (k1 + std::sqrt(det)));
    };
    auto var_out = [n, sb2, sg2](double c) {
        double nc = n - c;
        return (nc / n) * (sb2 - nc * sg2);
    };
    return std::min(var_out(1), var_out(std::min(c_max(0.), c_max(mg_min)))) / sb2;
}





Add Discussion as Guest

Log in