123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #ifndef BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005
- #define BOOST_ACCUMULATORS_STATISTICS_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/moment.hpp>
- #include <boost/accumulators/statistics/mean.hpp>
- namespace boost { namespace accumulators
- {
- namespace impl
- {
-
-
-
- template<typename Sample>
- struct skewness_impl
- : accumulator_base
- {
-
- typedef typename numeric::functional::fdiv<Sample, Sample>::result_type result_type;
- skewness_impl(dont_care)
- {
- }
- template<typename Args>
- result_type result(Args const &args) const
- {
- return numeric::fdiv(
- accumulators::moment<3>(args)
- - 3. * accumulators::moment<2>(args) * mean(args)
- + 2. * mean(args) * mean(args) * mean(args)
- , ( accumulators::moment<2>(args) - mean(args) * mean(args) )
- * std::sqrt( accumulators::moment<2>(args) - mean(args) * mean(args) )
- );
- }
-
-
- template<class Archive>
- void serialize(Archive & ar, const unsigned int file_version) {}
- };
- }
- namespace tag
- {
- struct skewness
- : depends_on<mean, moment<2>, moment<3> >
- {
-
-
- typedef accumulators::impl::skewness_impl<mpl::_1> impl;
- };
- }
- namespace extract
- {
- extractor<tag::skewness> const skewness = {};
- BOOST_ACCUMULATORS_IGNORE_GLOBAL(skewness)
- }
- using extract::skewness;
- template<>
- struct as_weighted_feature<tag::skewness>
- {
- typedef tag::weighted_skewness type;
- };
- template<>
- struct feature_of<tag::weighted_skewness>
- : feature_of<tag::skewness>
- {
- };
- }}
- #endif
|