| 7002 | |
| 7003 | template <typename Estimator, typename Iterator> |
| 7004 | sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { |
| 7005 | auto n = last - first; |
| 7006 | auto second = std::next(first); |
| 7007 | sample results; |
| 7008 | results.reserve(n); |
| 7009 | |
| 7010 | for (auto it = first; it != last; ++it) { |
| 7011 | std::iter_swap(it, first); |
| 7012 | results.push_back(estimator(second, last)); |
| 7013 | } |
| 7014 | |
| 7015 | return results; |
| 7016 | } |
| 7017 | |
| 7018 | inline double normal_cdf(double x) { |
| 7019 | return std::erfc(-x / std::sqrt(2.0)) / 2.0; |