/usr/include/boost/accumulators/statistics/kurtosis.hpp is in libboost1.55-dev 1.55.0+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | ///////////////////////////////////////////////////////////////////////////////
// kurtosis.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_KURTOSIS_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_STATISTICS_KURTOSIS_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/mean.hpp>
#include <boost/accumulators/statistics/moment.hpp>
namespace boost { namespace accumulators
{
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
// kurtosis_impl
/**
@brief Kurtosis estimation
The kurtosis of a sample distribution is defined as the ratio of the 4th central moment and the square of the 2nd central
moment (the variance) of the samples, minus 3. The term \f$ -3 \f$ is added in order to ensure that the normal distribution
has zero kurtosis. The kurtosis can also be expressed by the simple moments:
\f[
\hat{g}_2 =
\frac
{\widehat{m}_n^{(4)}-4\widehat{m}_n^{(3)}\hat{\mu}_n+6\widehat{m}_n^{(2)}\hat{\mu}_n^2-3\hat{\mu}_n^4}
{\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^2} - 3,
\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<typename Sample>
struct kurtosis_impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, Sample>::result_type result_type;
kurtosis_impl(dont_care) {}
template<typename Args>
result_type result(Args const &args) const
{
return numeric::fdiv(
accumulators::moment<4>(args)
- 4. * accumulators::moment<3>(args) * mean(args)
+ 6. * accumulators::moment<2>(args) * mean(args) * mean(args)
- 3. * mean(args) * mean(args) * mean(args) * mean(args)
, ( accumulators::moment<2>(args) - mean(args) * mean(args) )
* ( accumulators::moment<2>(args) - mean(args) * mean(args) )
) - 3.;
}
};
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
// tag::kurtosis
//
namespace tag
{
struct kurtosis
: depends_on<mean, moment<2>, moment<3>, moment<4> >
{
/// INTERNAL ONLY
///
typedef accumulators::impl::kurtosis_impl<mpl::_1> impl;
};
}
///////////////////////////////////////////////////////////////////////////////
// extract::kurtosis
//
namespace extract
{
extractor<tag::kurtosis> const kurtosis = {};
BOOST_ACCUMULATORS_IGNORE_GLOBAL(kurtosis)
}
using extract::kurtosis;
// So that kurtosis can be automatically substituted with
// weighted_kurtosis when the weight parameter is non-void
template<>
struct as_weighted_feature<tag::kurtosis>
{
typedef tag::weighted_kurtosis type;
};
template<>
struct feature_of<tag::weighted_kurtosis>
: feature_of<tag::kurtosis>
{
};
}} // namespace boost::accumulators
#endif
|