MCPcopy Create free account
hub / github.com/Profactor/cv-plot / resample

Function resample

CvPlot/ext/catch2/inc/catch.hpp:6930–6944  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6928
6929 template <typename URng, typename Iterator, typename Estimator>
6930 sample resample(URng& rng, int resamples, Iterator first, Iterator last, Estimator& estimator) {
6931 auto n = last - first;
6932 std::uniform_int_distribution<decltype(n)> dist(0, n - 1);
6933
6934 sample out;
6935 out.reserve(resamples);
6936 std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] {
6937 std::vector<double> resampled;
6938 resampled.reserve(n);
6939 std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; });
6940 return estimator(resampled.begin(), resampled.end());
6941 });
6942 std::sort(out.begin(), out.end());
6943 return out;
6944 }
6945
6946 template <typename Estimator, typename Iterator>
6947 sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {

Callers 1

analyse_samplesFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected