| 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, |
no test coverage detected