/usr/include/boost/accumulators/statistics
NameSizeModeActions
parameters/-0755rm
variates/-0755rm
count.hpp20130644editdlrm
covariance.hpp71370644editdlrm
density.hpp100070644editdlrm
error_of.hpp25880644editdlrm
error_of_mean.hpp21930644editdlrm
extended_p_square.hpp116330644editdlrm
extended_p_square_quantile.hpp125220644editdlrm
kurtosis.hpp38640644editdlrm
max.hpp22940644editdlrm
mean.hpp93340644editdlrm
median.hpp102420644editdlrm
min.hpp22940644editdlrm
moment.hpp34360644editdlrm
peaks_over_threshold.hpp175250644editdlrm
pot_quantile.hpp73360644editdlrm
pot_tail_mean.hpp78020644editdlrm
p_square_cumulative_distribution.hpp9550644editdlrm
p_square_cumul_dist.hpp103650644editdlrm
p_square_quantile.hpp100860644editdlrm
rolling_count.hpp25740644editdlrm
rolling_mean.hpp67530644editdlrm
rolling_moment.hpp37410644editdlrm
rolling_sum.hpp28710644editdlrm
rolling_variance.hpp94860644editdlrm
rolling_window.hpp72540644editdlrm
skewness.hpp36910644editdlrm
stats.hpp9720644editdlrm
sum.hpp38840644editdlrm
sum_kahan.hpp51040644editdlrm
tail.hpp110120644editdlrm
tail_mean.hpp91580644editdlrm
tail_quantile.hpp55350644editdlrm
tail_variate.hpp45040644editdlrm
tail_variate_means.hpp104630644editdlrm
times2_iterator.hpp19650644editdlrm
variance.hpp75220644editdlrm
weighted_covariance.hpp52440644editdlrm
weighted_density.hpp95180644editdlrm
weighted_extended_p_square.hpp128420644editdlrm
weighted_kurtosis.hpp41470644editdlrm
weighted_mean.hpp66370644editdlrm
weighted_median.hpp86670644editdlrm
weighted_moment.hpp33840644editdlrm
weighted_peaks_over_threshold.hpp123520644editdlrm
weighted_p_square_cumulative_distribution.hpp10090644editdlrm
weighted_p_square_cumul_dist.hpp110580644editdlrm
weighted_p_square_quantile.hpp111100644editdlrm
weighted_skewness.hpp38440644editdlrm
weighted_sum.hpp36390644editdlrm
weighted_sum_kahan.hpp45590644editdlrm
weighted_tail_mean.hpp57880644editdlrm
weighted_tail_quantile.hpp51350644editdlrm
weighted_tail_variate_means.hpp100520644editdlrm
weighted_variance.hpp67740644editdlrm
with_error.hpp12770644editdlrm
Edit: /usr/include/boost/accumulators/statistics/median.hpp (10242B)
/////////////////////////////////////////////////////////////////////////////// // median.hpp // // Copyright 2006 Eric Niebler, Olivier Gygi. 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_MEDIAN_HPP_EAN_28_10_2005 #define BOOST_ACCUMULATORS_STATISTICS_MEDIAN_HPP_EAN_28_10_2005 #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace accumulators { namespace impl { /////////////////////////////////////////////////////////////////////////////// // median_impl // /** @brief Median estimation based on the \f$P^2\f$ quantile estimator The \f$P^2\f$ algorithm is invoked with a quantile probability of 0.5. */ template struct median_impl : accumulator_base { // for boost::result_of typedef typename numeric::functional::fdiv::result_type result_type; median_impl(dont_care) {} template result_type result(Args const &args) const { return p_square_quantile_for_median(args); } // serialization is done by accumulators it depends on template void serialize(Archive & ar, const unsigned int file_version) {} }; /////////////////////////////////////////////////////////////////////////////// // with_density_median_impl // /** @brief Median estimation based on the density estimator The algorithm determines the bin in which the \f$0.5*cnt\f$-th sample lies, \f$cnt\f$ being the total number of samples. It returns the approximate horizontal position of this sample, based on a linear interpolation inside the bin. */ template struct with_density_median_impl : accumulator_base { typedef typename numeric::functional::fdiv::result_type float_type; typedef std::vector > histogram_type; typedef iterator_range range_type; // for boost::result_of typedef float_type result_type; template with_density_median_impl(Args const &args) : sum(numeric::fdiv(args[sample | Sample()], (std::size_t)1)) , is_dirty(true) { } void operator ()(dont_care) { this->is_dirty = true; } template result_type result(Args const &args) const { if (this->is_dirty) { this->is_dirty = false; std::size_t cnt = count(args); range_type histogram = density(args); typename range_type::iterator it = histogram.begin(); while (this->sum < 0.5 * cnt) { this->sum += it->second * cnt; ++it; } --it; float_type over = numeric::fdiv(this->sum - 0.5 * cnt, it->second * cnt); this->median = it->first * over + (it + 1)->first * (1. - over); } return this->median; } // make this accumulator serializeable template void serialize(Archive & ar, const unsigned int file_version) { ar & sum; ar & is_dirty; ar & median; } private: mutable float_type sum; mutable bool is_dirty; mutable float_type median; }; /////////////////////////////////////////////////////////////////////////////// // with_p_square_cumulative_distribution_median_impl // /** @brief Median estimation based on the \f$P^2\f$ cumulative distribution estimator The algorithm determines the first (leftmost) bin with a height exceeding 0.5. It returns the approximate horizontal position of where the cumulative distribution equals 0.5, based on a linear interpolation inside the bin. */ template struct with_p_square_cumulative_distribution_median_impl : accumulator_base { typedef typename numeric::functional::fdiv::result_type float_type; typedef std::vector > histogram_type; typedef iterator_range range_type; // for boost::result_of typedef float_type result_type; with_p_square_cumulative_distribution_median_impl(dont_care) : is_dirty(true) { } void operator ()(dont_care) { this->is_dirty = true; } template result_type result(Args const &args) const { if (this->is_dirty) { this->is_dirty = false; range_type histogram = p_square_cumulative_distribution(args); typename range_type::iterator it = histogram.begin(); while (it->second < 0.5) { ++it; } float_type over = numeric::fdiv(it->second - 0.5, it->second - (it - 1)->second); this->median = it->first * over + (it + 1)->first * ( 1. - over ); } return this->median; } // make this accumulator serializeable template void serialize(Archive & ar, const unsigned int file_version) { ar & is_dirty; ar & median; } private: mutable bool is_dirty; mutable float_type median; }; } // namespace impl /////////////////////////////////////////////////////////////////////////////// // tag::median // tag::with_densisty_median // tag::with_p_square_cumulative_distribution_median // namespace tag { struct median : depends_on { /// INTERNAL ONLY /// typedef accumulators::impl::median_impl impl; }; struct with_density_median : depends_on { /// INTERNAL ONLY /// typedef accumulators::impl::with_density_median_impl impl; }; struct with_p_square_cumulative_distribution_median : depends_on { /// INTERNAL ONLY /// typedef accumulators::impl::with_p_square_cumulative_distribution_median_impl impl; }; } /////////////////////////////////////////////////////////////////////////////// // extract::median // extract::with_density_median // extract::with_p_square_cumulative_distribution_median // namespace extract { extractor const median = {}; extractor const with_density_median = {}; extractor const with_p_square_cumulative_distribution_median = {}; BOOST_ACCUMULATORS_IGNORE_GLOBAL(median) BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_density_median) BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_p_square_cumulative_distribution_median) } using extract::median; using extract::with_density_median; using extract::with_p_square_cumulative_distribution_median; // median(with_p_square_quantile) -> median template<> struct as_feature { typedef tag::median type; }; // median(with_density) -> with_density_median template<> struct as_feature { typedef tag::with_density_median type; }; // median(with_p_square_cumulative_distribution) -> with_p_square_cumulative_distribution_median template<> struct as_feature { typedef tag::with_p_square_cumulative_distribution_median type; }; // for the purposes of feature-based dependency resolution, // with_density_median and with_p_square_cumulative_distribution_median // provide the same feature as median template<> struct feature_of : feature_of { }; template<> struct feature_of : feature_of { }; // So that median can be automatically substituted with // weighted_median when the weight parameter is non-void. template<> struct as_weighted_feature { typedef tag::weighted_median type; }; template<> struct feature_of : feature_of { }; // So that with_density_median can be automatically substituted with // with_density_weighted_median when the weight parameter is non-void. template<> struct as_weighted_feature { typedef tag::with_density_weighted_median type; }; template<> struct feature_of : feature_of { }; // So that with_p_square_cumulative_distribution_median can be automatically substituted with // with_p_square_cumulative_distribution_weighted_median when the weight parameter is non-void. template<> struct as_weighted_feature { typedef tag::with_p_square_cumulative_distribution_weighted_median type; }; template<> struct feature_of : feature_of { }; }} // namespace boost::accumulators #endif