123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005
- #define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005
- #include <limits>
- #include <boost/mpl/placeholders.hpp>
- #include <boost/accumulators/framework/accumulator_base.hpp>
- #include <boost/accumulators/framework/extractor.hpp>
- #include <boost/accumulators/framework/parameters/sample.hpp>
- #include <boost/accumulators/numeric/functional.hpp>
- #include <boost/accumulators/framework/depends_on.hpp>
- #include <boost/accumulators/statistics_fwd.hpp>
- #include <boost/accumulators/statistics/weighted_moment.hpp>
- #include <boost/accumulators/statistics/weighted_mean.hpp>
- namespace boost { namespace accumulators
- {
- namespace impl
- {
-
-
-
- template<typename Sample, typename Weight>
- struct weighted_skewness_impl
- : accumulator_base
- {
- typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
-
- typedef typename numeric::functional::fdiv<weighted_sample, weighted_sample>::result_type result_type;
- weighted_skewness_impl(dont_care) {}
- template<typename Args>
- result_type result(Args const &args) const
- {
- return numeric::fdiv(
- accumulators::weighted_moment<3>(args)
- - 3. * accumulators::weighted_moment<2>(args) * weighted_mean(args)
- + 2. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args)
- , ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) )
- * std::sqrt( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) )
- );
- }
- };
- }
- namespace tag
- {
- struct weighted_skewness
- : depends_on<weighted_mean, weighted_moment<2>, weighted_moment<3> >
- {
-
-
- typedef accumulators::impl::weighted_skewness_impl<mpl::_1, mpl::_2> impl;
- };
- }
- namespace extract
- {
- extractor<tag::weighted_skewness> const weighted_skewness = {};
- BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_skewness)
- }
- using extract::weighted_skewness;
- }}
- #endif
|