/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/density.hpp (10007B)
/////////////////////////////////////////////////////////////////////////////// // density.hpp // // Copyright 2006 Daniel Egloff, 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_DENSITY_HPP_DE_01_01_2006 #define BOOST_ACCUMULATORS_STATISTICS_DENSITY_HPP_DE_01_01_2006 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace accumulators { /////////////////////////////////////////////////////////////////////////////// // cache_size and num_bins named parameters // BOOST_PARAMETER_NESTED_KEYWORD(tag, density_cache_size, cache_size) BOOST_PARAMETER_NESTED_KEYWORD(tag, density_num_bins, num_bins) BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_cache_size) BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_num_bins) namespace impl { /////////////////////////////////////////////////////////////////////////////// // density_impl // density histogram /** @brief Histogram density estimator The histogram density estimator returns a histogram of the sample distribution. The positions and sizes of the bins are determined using a specifiable number of cached samples (cache_size). The range between the minimum and the maximum of the cached samples is subdivided into a specifiable number of bins (num_bins) of same size. Additionally, an under- and an overflow bin is added to capture future under- and overflow samples. Once the bins are determined, the cached samples and all subsequent samples are added to the correct bins. At the end, a range of std::pair is return, where each pair contains the position of the bin (lower bound) and the samples count (normalized with the total number of samples). @param density_cache_size Number of first samples used to determine min and max. @param density_num_bins Number of bins (two additional bins collect under- and overflow samples). */ template struct density_impl : accumulator_base { typedef typename numeric::functional::fdiv::result_type float_type; typedef std::vector > histogram_type; typedef std::vector array_type; // for boost::result_of typedef iterator_range result_type; template density_impl(Args const &args) : cache_size(args[density_cache_size]) , cache(cache_size) , num_bins(args[density_num_bins]) , samples_in_bin(num_bins + 2, 0.) , bin_positions(num_bins + 2) , histogram( num_bins + 2 , std::make_pair( numeric::fdiv(args[sample | Sample()],(std::size_t)1) , numeric::fdiv(args[sample | Sample()],(std::size_t)1) ) ) , is_dirty(true) { } template void operator ()(Args const &args) { this->is_dirty = true; std::size_t cnt = count(args); // Fill up cache with cache_size first samples if (cnt <= this->cache_size) { this->cache[cnt - 1] = args[sample]; } // Once cache_size samples have been accumulated, create num_bins bins of same size between // the minimum and maximum of the cached samples as well as under and overflow bins. // Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin). if (cnt == this->cache_size) { float_type minimum = numeric::fdiv((min)(args), (std::size_t)1); float_type maximum = numeric::fdiv((max)(args), (std::size_t)1); float_type bin_size = numeric::fdiv(maximum - minimum, this->num_bins ); // determine bin positions (their lower bounds) for (std::size_t i = 0; i < this->num_bins + 2; ++i) { this->bin_positions[i] = minimum + (i - 1.) * bin_size; } for (typename array_type::const_iterator iter = this->cache.begin(); iter != this->cache.end(); ++iter) { if (*iter < this->bin_positions[1]) { ++(this->samples_in_bin[0]); } else if (*iter >= this->bin_positions[this->num_bins + 1]) { ++(this->samples_in_bin[this->num_bins + 1]); } else { typename array_type::iterator it = std::upper_bound( this->bin_positions.begin() , this->bin_positions.end() , *iter ); std::size_t d = std::distance(this->bin_positions.begin(), it); ++(this->samples_in_bin[d - 1]); } } } // Add each subsequent sample to the correct bin else if (cnt > this->cache_size) { if (args[sample] < this->bin_positions[1]) { ++(this->samples_in_bin[0]); } else if (args[sample] >= this->bin_positions[this->num_bins + 1]) { ++(this->samples_in_bin[this->num_bins + 1]); } else { typename array_type::iterator it = std::upper_bound( this->bin_positions.begin() , this->bin_positions.end() , args[sample] ); std::size_t d = std::distance(this->bin_positions.begin(), it); ++(this->samples_in_bin[d - 1]); } } } /** @pre The number of samples must meet or exceed the cache size */ template result_type result(Args const &args) const { if (this->is_dirty) { this->is_dirty = false; // creates a vector of std::pair where each pair i holds // the values bin_positions[i] (x-axis of histogram) and // samples_in_bin[i] / cnt (y-axis of histogram). for (std::size_t i = 0; i < this->num_bins + 2; ++i) { this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::fdiv(this->samples_in_bin[i], count(args))); } } // returns a range of pairs return make_iterator_range(this->histogram); } // make this accumulator serializeable // TODO split to save/load and check on parameters provided in ctor template void serialize(Archive & ar, const unsigned int file_version) { ar & cache_size; ar & cache; ar & num_bins; ar & samples_in_bin; ar & bin_positions; ar & histogram; ar & is_dirty; } private: std::size_t cache_size; // number of cached samples array_type cache; // cache to store the first cache_size samples std::size_t num_bins; // number of bins array_type samples_in_bin; // number of samples in each bin array_type bin_positions; // lower bounds of bins mutable histogram_type histogram; // histogram mutable bool is_dirty; }; } // namespace impl /////////////////////////////////////////////////////////////////////////////// // tag::density // namespace tag { struct density : depends_on , density_cache_size , density_num_bins { /// INTERNAL ONLY /// typedef accumulators::impl::density_impl impl; #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED /// tag::density::cache_size named parameter /// tag::density::num_bins named parameter static boost::parameter::keyword const cache_size; static boost::parameter::keyword const num_bins; #endif }; } /////////////////////////////////////////////////////////////////////////////// // extract::density // namespace extract { extractor const density = {}; BOOST_ACCUMULATORS_IGNORE_GLOBAL(density) } using extract::density; // So that density can be automatically substituted // with weighted_density when the weight parameter is non-void. template<> struct as_weighted_feature { typedef tag::weighted_density type; }; template<> struct feature_of : feature_of { }; }} // namespace boost::accumulators #endif