/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/extended_p_square_quantile.hpp (12522B)
/////////////////////////////////////////////////////////////////////////////// // extended_p_square_quantile.hpp // // Copyright 2005 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_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 #define BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4127) // conditional expression is constant #endif namespace boost { namespace accumulators { namespace impl { /////////////////////////////////////////////////////////////////////////////// // extended_p_square_quantile_impl // single quantile estimation /** @brief Quantile estimation using the extended \f$P^2\f$ algorithm for weighted and unweighted samples Uses the quantile estimates calculated by the extended \f$P^2\f$ algorithm to compute intermediate quantile estimates by means of quadratic interpolation. @param quantile_probability The probability of the quantile to be estimated. */ template // Impl1: weighted/unweighted // Impl2: linear/quadratic struct extended_p_square_quantile_impl : accumulator_base { typedef typename numeric::functional::fdiv::result_type float_type; typedef std::vector array_type; typedef iterator_range< detail::lvalue_index_iterator< permutation_iterator< typename array_type::const_iterator , detail::times2_iterator > > > range_type; // for boost::result_of typedef float_type result_type; template extended_p_square_quantile_impl(Args const &args) : probabilities( boost::begin(args[extended_p_square_probabilities]) , boost::end(args[extended_p_square_probabilities]) ) { } template result_type result(Args const &args) const { typedef typename mpl::if_< is_same , tag::weighted_extended_p_square , tag::extended_p_square >::type extended_p_square_tag; extractor const some_extended_p_square = {}; array_type heights(some_extended_p_square(args).size()); std::copy(some_extended_p_square(args).begin(), some_extended_p_square(args).end(), heights.begin()); this->probability = args[quantile_probability]; typename array_type::const_iterator iter_probs = std::lower_bound(this->probabilities.begin(), this->probabilities.end(), this->probability); std::size_t dist = std::distance(this->probabilities.begin(), iter_probs); typename array_type::const_iterator iter_heights = heights.begin() + dist; // If this->probability is not in a valid range return NaN or throw exception if (this->probability < *this->probabilities.begin() || this->probability > *(this->probabilities.end() - 1)) { if (std::numeric_limits::has_quiet_NaN) { return std::numeric_limits::quiet_NaN(); } else { std::ostringstream msg; msg << "probability = " << this->probability << " is not in valid range ("; msg << *this->probabilities.begin() << ", " << *(this->probabilities.end() - 1) << ")"; boost::throw_exception(std::runtime_error(msg.str())); return Sample(0); } } if (*iter_probs == this->probability) { return heights[dist]; } else { result_type res; if (is_same::value) { ///////////////////////////////////////////////////////////////////////////////// // LINEAR INTERPOLATION // float_type p1 = *iter_probs; float_type p0 = *(iter_probs - 1); float_type h1 = *iter_heights; float_type h0 = *(iter_heights - 1); float_type a = numeric::fdiv(h1 - h0, p1 - p0); float_type b = h1 - p1 * a; res = a * this->probability + b; } else { ///////////////////////////////////////////////////////////////////////////////// // QUADRATIC INTERPOLATION // float_type p0, p1, p2; float_type h0, h1, h2; if ( (dist == 1 || *iter_probs - this->probability <= this->probability - *(iter_probs - 1) ) && dist != this->probabilities.size() - 1 ) { p0 = *(iter_probs - 1); p1 = *iter_probs; p2 = *(iter_probs + 1); h0 = *(iter_heights - 1); h1 = *iter_heights; h2 = *(iter_heights + 1); } else { p0 = *(iter_probs - 2); p1 = *(iter_probs - 1); p2 = *iter_probs; h0 = *(iter_heights - 2); h1 = *(iter_heights - 1); h2 = *iter_heights; } float_type hp21 = numeric::fdiv(h2 - h1, p2 - p1); float_type hp10 = numeric::fdiv(h1 - h0, p1 - p0); float_type p21 = numeric::fdiv(p2 * p2 - p1 * p1, p2 - p1); float_type p10 = numeric::fdiv(p1 * p1 - p0 * p0, p1 - p0); float_type a = numeric::fdiv(hp21 - hp10, p21 - p10); float_type b = hp21 - a * p21; float_type c = h2 - a * p2 * p2 - b * p2; res = a * this->probability * this-> probability + b * this->probability + c; } return res; } } public: // make this accumulator serializeable // TODO: do we need to split to load/save and verify that the parameters did not change? template void serialize(Archive & ar, const unsigned int file_version) { ar & probabilities; ar & probability; } private: array_type probabilities; mutable float_type probability; }; } // namespace impl /////////////////////////////////////////////////////////////////////////////// // tag::extended_p_square_quantile // namespace tag { struct extended_p_square_quantile : depends_on { typedef accumulators::impl::extended_p_square_quantile_impl impl; }; struct extended_p_square_quantile_quadratic : depends_on { typedef accumulators::impl::extended_p_square_quantile_impl impl; }; struct weighted_extended_p_square_quantile : depends_on { typedef accumulators::impl::extended_p_square_quantile_impl impl; }; struct weighted_extended_p_square_quantile_quadratic : depends_on { typedef accumulators::impl::extended_p_square_quantile_impl impl; }; } /////////////////////////////////////////////////////////////////////////////// // extract::extended_p_square_quantile // extract::weighted_extended_p_square_quantile // namespace extract { extractor const extended_p_square_quantile = {}; extractor const extended_p_square_quantile_quadratic = {}; extractor const weighted_extended_p_square_quantile = {}; extractor const weighted_extended_p_square_quantile_quadratic = {}; BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile) BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile_quadratic) BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile) BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile_quadratic) } using extract::extended_p_square_quantile; using extract::extended_p_square_quantile_quadratic; using extract::weighted_extended_p_square_quantile; using extract::weighted_extended_p_square_quantile_quadratic; // extended_p_square_quantile(linear) -> extended_p_square_quantile template<> struct as_feature { typedef tag::extended_p_square_quantile type; }; // extended_p_square_quantile(quadratic) -> extended_p_square_quantile_quadratic template<> struct as_feature { typedef tag::extended_p_square_quantile_quadratic type; }; // weighted_extended_p_square_quantile(linear) -> weighted_extended_p_square_quantile template<> struct as_feature { typedef tag::weighted_extended_p_square_quantile type; }; // weighted_extended_p_square_quantile(quadratic) -> weighted_extended_p_square_quantile_quadratic template<> struct as_feature { typedef tag::weighted_extended_p_square_quantile_quadratic type; }; // for the purposes of feature-based dependency resolution, // extended_p_square_quantile and weighted_extended_p_square_quantile // provide the same feature as quantile template<> struct feature_of : feature_of { }; template<> struct feature_of : feature_of { }; // So that extended_p_square_quantile can be automatically substituted with // weighted_extended_p_square_quantile when the weight parameter is non-void template<> struct as_weighted_feature { typedef tag::weighted_extended_p_square_quantile type; }; template<> struct feature_of : feature_of { }; // So that extended_p_square_quantile_quadratic can be automatically substituted with // weighted_extended_p_square_quantile_quadratic when the weight parameter is non-void template<> struct as_weighted_feature { typedef tag::weighted_extended_p_square_quantile_quadratic type; }; template<> struct feature_of : feature_of { }; }} // namespace boost::accumulators #ifdef _MSC_VER # pragma warning(pop) #endif #endif