MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / analyse_samples

Function analyse_samples

extlibs/catch/include/catch/catch.hpp:7495–7535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7493 }
7494
7495 bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
7496 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
7497 static std::random_device entropy;
7498 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS
7499
7500 auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
7501
7502 auto mean = &Detail::mean<std::vector<double>::iterator>;
7503 auto stddev = &standard_deviation;
7504
7505#if defined(CATCH_CONFIG_USE_ASYNC)
7506 auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
7507 auto seed = entropy();
7508 return std::async(std::launch::async, [=] {
7509 std::mt19937 rng(seed);
7510 auto resampled = resample(rng, n_resamples, first, last, f);
7511 return bootstrap(confidence_level, first, last, resampled, f);
7512 });
7513 };
7514
7515 auto mean_future = Estimate(mean);
7516 auto stddev_future = Estimate(stddev);
7517
7518 auto mean_estimate = mean_future.get();
7519 auto stddev_estimate = stddev_future.get();
7520#else
7521 auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
7522 auto seed = entropy();
7523 std::mt19937 rng(seed);
7524 auto resampled = resample(rng, n_resamples, first, last, f);
7525 return bootstrap(confidence_level, first, last, resampled, f);
7526 };
7527
7528 auto mean_estimate = Estimate(mean);
7529 auto stddev_estimate = Estimate(stddev);
7530#endif // CATCH_USE_ASYNC
7531
7532 double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n);
7533
7534 return { mean_estimate, stddev_estimate, outlier_variance };
7535 }
7536 } // namespace Detail
7537 } // namespace Benchmark
7538} // namespace Catch

Callers 1

analyseFunction · 0.85

Calls 5

bootstrapFunction · 0.85
EstimateClass · 0.85
outlier_varianceFunction · 0.85
resampleFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected