Statistics
| Revision:

## root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / accumulators / statistics / skewness.hpp @ 2486

 1 ///////////////////////////////////////////////////////////////////////////////  // skewness.hpp  //  // Copyright 2006 Olivier Gygi, Daniel Egloff. Distributed under the Boost  // Software License, Version 1.0. (See accompanying file  // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)  #ifndef BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005  #define BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  namespace boost { namespace accumulators  {  namespace impl  {   ///////////////////////////////////////////////////////////////////////////////   // skewness_impl   /**   @brief Skewness estimation     The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$3/2 \f$-th power   of the 2nd central moment (the variance) of the samples 3. The skewness can also be expressed by the simple moments:     \f[   \hat{g}_1 =   \frac   {\widehat{m}_n^{(3)}-3\widehat{m}_n^{(2)}\hat{\mu}_n+2\hat{\mu}_n^3}   {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^{3/2}}   \f]     where \f$\widehat{m}_n^{(i)} \f$ are the \f$i \f$-th moment and \f$\hat{\mu}_n \f$ the mean (first moment) of the   \f$n \f$ samples.   */   template   struct skewness_impl   : accumulator_base   {   // for boost::result_of   typedef typename numeric::functional::fdiv::result_type result_type;   skewness_impl(dont_care)   {   }   template   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) )   );   }   };  } // namespace impl  ///////////////////////////////////////////////////////////////////////////////  // tag::skewness  //  namespace tag  {   struct skewness   : depends_on, moment<3> >   {   /// INTERNAL ONLY   ///   typedef accumulators::impl::skewness_impl impl;   };  }  ///////////////////////////////////////////////////////////////////////////////  // extract::skewness  //  namespace extract  {   extractor const skewness = {};   BOOST_ACCUMULATORS_IGNORE_GLOBAL(skewness)  }  using extract::skewness;  // So that skewness can be automatically substituted with  // weighted_skewness when the weight parameter is non-void  template<>  struct as_weighted_feature  {   typedef tag::weighted_skewness type;  };  template<>  struct feature_of   : feature_of  {  };  }} // namespace boost::accumulators  #endif