1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef BOOST_HISTOGRAM_UTILITY_WALD_INTERVAL_HPP
- #define BOOST_HISTOGRAM_UTILITY_WALD_INTERVAL_HPP
- #include <boost/histogram/fwd.hpp>
- #include <boost/histogram/utility/binomial_proportion_interval.hpp>
- #include <cmath>
- #include <utility>
- namespace boost {
- namespace histogram {
- namespace utility {
- template <class ValueType>
- class wald_interval : public binomial_proportion_interval<ValueType> {
- public:
- using value_type = typename wald_interval::value_type;
- using interval_type = typename wald_interval::interval_type;
-
- explicit wald_interval(deviation d = deviation{1.0}) noexcept
- : z_{static_cast<value_type>(d)} {}
- using binomial_proportion_interval<ValueType>::operator();
-
- interval_type operator()(value_type successes, value_type failures) const noexcept {
-
-
-
- const value_type total_inv = 1 / (successes + failures);
- const value_type a = successes * total_inv;
- const value_type b = (z_ * total_inv) * std::sqrt(successes * failures * total_inv);
- return {a - b, a + b};
- }
- private:
- value_type z_;
- };
- }
- }
- }
- #endif
|