Fix some messy formatting in catch_stats

This commit is contained in:
Martin Hořeňovský 2022-03-06 11:02:20 +01:00
parent 05d4ec62c8
commit f206162b2d
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 12 additions and 7 deletions

View File

@ -119,11 +119,15 @@ using Catch::Benchmark::Detail::sample;
double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) { double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) {
auto m = Catch::Benchmark::Detail::mean(first, last); auto m = Catch::Benchmark::Detail::mean(first, last);
double variance = std::accumulate(first, last, 0., [m](double a, double b) { double variance = std::accumulate( first,
double diff = b - m; last,
return a + diff * diff; 0.,
}) / (last - first); [m]( double a, double b ) {
return std::sqrt(variance); double diff = b - m;
return a + diff * diff;
} ) /
( last - first );
return std::sqrt( variance );
} }
} }

View File

@ -108,8 +108,9 @@ namespace Catch {
double bias = normal_quantile(prob_n); double bias = normal_quantile(prob_n);
double z1 = normal_quantile((1. - confidence_level) / 2.); double z1 = normal_quantile((1. - confidence_level) / 2.);
auto cumn = [n](double x) -> int { auto cumn = [n]( double x ) -> int {
return std::lround(normal_cdf(x) * n); }; return std::lround( normal_cdf( x ) * n );
};
auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); }; auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); };
double b1 = bias + z1; double b1 = bias + z1;
double b2 = bias - z1; double b2 = bias - z1;