Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:19

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // error_of.hpp
0003 //
0004 //  Copyright 2005 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006
0009 #define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006
0010 
0011 #include <boost/mpl/placeholders.hpp>
0012 #include <boost/accumulators/framework/accumulator_base.hpp>
0013 #include <boost/accumulators/framework/extractor.hpp>
0014 #include <boost/accumulators/framework/depends_on.hpp>
0015 #include <boost/accumulators/statistics_fwd.hpp>
0016 #include <boost/accumulators/statistics/error_of.hpp>
0017 #include <boost/accumulators/statistics/variance.hpp>
0018 #include <boost/accumulators/statistics/count.hpp>
0019 
0020 namespace boost { namespace accumulators
0021 {
0022 
0023 namespace impl
0024 {
0025     ///////////////////////////////////////////////////////////////////////////////
0026     // error_of_mean_impl
0027     template<typename Sample, typename Variance>
0028     struct error_of_mean_impl
0029       : accumulator_base
0030     {
0031         // for boost::result_of
0032         typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
0033 
0034         error_of_mean_impl(dont_care) {}
0035 
0036         template<typename Args>
0037         result_type result(Args const &args) const
0038         {
0039             using namespace std;
0040             extractor<Variance> const variance = {};
0041             return sqrt(numeric::fdiv(variance(args), count(args) - 1));
0042         }
0043     };
0044 
0045 } // namespace impl
0046 
0047 ///////////////////////////////////////////////////////////////////////////////
0048 // tag::error_of
0049 //
0050 namespace tag
0051 {
0052     template<>
0053     struct error_of<mean>
0054       : depends_on<lazy_variance, count>
0055     {
0056         /// INTERNAL ONLY
0057         ///
0058         typedef accumulators::impl::error_of_mean_impl<mpl::_1, lazy_variance> impl;
0059     };
0060 
0061     template<>
0062     struct error_of<immediate_mean>
0063       : depends_on<variance, count>
0064     {
0065         /// INTERNAL ONLY
0066         ///
0067         typedef accumulators::impl::error_of_mean_impl<mpl::_1, variance> impl;
0068     };
0069 }
0070 
0071 }} // namespace boost::accumulators
0072 
0073 #endif