1 ///////////////////////////////////////////////////////////////////////////////
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
25 ///////////////////////////////////////////////////////////////////////////////
27 template<typename Sample
, typename Variance
>
28 struct error_of_mean_impl
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
40 extractor
<Variance
> const variance
= {};
41 return sqrt(numeric::average(variance(args
), count(args
) - 1));
47 ///////////////////////////////////////////////////////////////////////////////
54 : depends_on
<lazy_variance
, count
>
58 typedef accumulators::impl::error_of_mean_impl
<mpl::_1
, lazy_variance
> impl
;
62 struct error_of
<immediate_mean
>
63 : depends_on
<variance
, count
>
67 typedef accumulators::impl::error_of_mean_impl
<mpl::_1
, variance
> impl
;
71 }} // namespace boost::accumulators