fix doc example typo
[boost.git] / boost / accumulators / statistics / error_of_mean.hpp
blob9451d40f733990fe9595d180266081f99ecc1d7c
1 ///////////////////////////////////////////////////////////////////////////////
2 // error_of.hpp
3 //
4 // Copyright 2005 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006
9 #define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006
11 #include <boost/mpl/placeholders.hpp>
12 #include <boost/accumulators/framework/accumulator_base.hpp>
13 #include <boost/accumulators/framework/extractor.hpp>
14 #include <boost/accumulators/framework/depends_on.hpp>
15 #include <boost/accumulators/statistics_fwd.hpp>
16 #include <boost/accumulators/statistics/error_of.hpp>
17 #include <boost/accumulators/statistics/variance.hpp>
18 #include <boost/accumulators/statistics/count.hpp>
20 namespace boost { namespace accumulators
23 namespace impl
25 ///////////////////////////////////////////////////////////////////////////////
26 // error_of_mean_impl
27 template<typename Sample, typename Variance>
28 struct error_of_mean_impl
29 : accumulator_base
31 // for boost::result_of
32 typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
34 error_of_mean_impl(dont_care) {}
36 template<typename Args>
37 result_type result(Args const &args) const
39 using namespace std;
40 extractor<Variance> const variance = {};
41 return sqrt(numeric::average(variance(args), count(args) - 1));
45 } // namespace impl
47 ///////////////////////////////////////////////////////////////////////////////
48 // tag::error_of
50 namespace tag
52 template<>
53 struct error_of<mean>
54 : depends_on<lazy_variance, count>
56 /// INTERNAL ONLY
57 ///
58 typedef accumulators::impl::error_of_mean_impl<mpl::_1, lazy_variance> impl;
61 template<>
62 struct error_of<immediate_mean>
63 : depends_on<variance, count>
65 /// INTERNAL ONLY
66 ///
67 typedef accumulators::impl::error_of_mean_impl<mpl::_1, variance> impl;
71 }} // namespace boost::accumulators
73 #endif