MCPcopy Create free account
hub / github.com/catchorg/Catch2 / resample

Function resample

extras/catch_amalgamated.cpp:189–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187
188 template <typename URng, typename Estimator>
189 static sample
190 resample( URng& rng,
191 unsigned int resamples,
192 double const* first,
193 double const* last,
194 Estimator& estimator ) {
195 auto n = static_cast<size_t>( last - first );
196 Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
197
198 sample out;
199 out.reserve( resamples );
200 std::vector<double> resampled;
201 resampled.reserve( n );
202 for ( size_t i = 0; i < resamples; ++i ) {
203 resampled.clear();
204 for ( size_t s = 0; s < n; ++s ) {
205 resampled.push_back( first[dist( rng )] );
206 }
207 const auto estimate =
208 estimator( resampled.data(), resampled.data() + resampled.size() );
209 out.push_back( estimate );
210 }
211 std::sort( out.begin(), out.end() );
212 return out;
213 }
214
215 static double outlier_variance( Estimate<double> mean,
216 Estimate<double> stddev,

Callers 1

analyse_samplesFunction · 0.70

Calls 4

clearMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected