| 6789 | |
| 6790 | template <typename Estimator, typename Iterator> |
| 6791 | sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { |
| 6792 | auto n = last - first; |
| 6793 | auto second = std::next(first); |
| 6794 | sample results; |
| 6795 | results.reserve(n); |
| 6796 | |
| 6797 | for (auto it = first; it != last; ++it) { |
| 6798 | std::iter_swap(it, first); |
| 6799 | results.push_back(estimator(second, last)); |
| 6800 | } |
| 6801 | |
| 6802 | return results; |
| 6803 | } |
| 6804 | |
| 6805 | inline double normal_cdf(double x) { |
| 6806 | return std::erfc(-x / std::sqrt(2.0)) / 2.0; |