MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / resample

Function resample

Source/ThirdParty/catch2/catch.hpp:6991–7005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6989
6990 template <typename URng, typename Iterator, typename Estimator>
6991 sample resample(URng& rng, int resamples, Iterator first, Iterator last, Estimator& estimator) {
6992 auto n = last - first;
6993 std::uniform_int_distribution<decltype(n)> dist(0, n - 1);
6994
6995 sample out;
6996 out.reserve(resamples);
6997 std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] {
6998 std::vector<double> resampled;
6999 resampled.reserve(n);
7000 std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; });
7001 return estimator(resampled.begin(), resampled.end());
7002 });
7003 std::sort(out.begin(), out.end());
7004 return out;
7005 }
7006
7007 template <typename Estimator, typename Iterator>
7008 sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {

Callers 1

analyse_samplesFunction · 0.85

Calls 5

back_inserterFunction · 0.85
sortFunction · 0.85
reserveMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected