123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- #ifndef BOOST_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006
- #define BOOST_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006
- #include <vector>
- #include <limits>
- #include <numeric>
- #include <functional>
- #include <boost/parameter/keyword.hpp>
- #include <boost/tuple/tuple.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/mpl/placeholders.hpp>
- #include <boost/accumulators/framework/accumulator_base.hpp>
- #include <boost/accumulators/framework/extractor.hpp>
- #include <boost/accumulators/numeric/functional.hpp>
- #include <boost/accumulators/framework/parameters/sample.hpp>
- #include <boost/accumulators/statistics_fwd.hpp>
- #include <boost/accumulators/statistics/tail.hpp>
- #include <boost/accumulators/statistics/peaks_over_threshold.hpp>
- #include <boost/accumulators/statistics/weighted_peaks_over_threshold.hpp>
- namespace boost { namespace accumulators
- {
- namespace impl
- {
-
-
-
-
- template<typename Sample, typename Impl, typename LeftRight>
- struct pot_quantile_impl
- : accumulator_base
- {
- typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
-
- typedef float_type result_type;
- pot_quantile_impl(dont_care)
- : sign_((is_same<LeftRight, left>::value) ? -1 : 1)
- {
- }
- template<typename Args>
- result_type result(Args const &args) const
- {
- typedef
- typename mpl::if_<
- is_same<Impl, weighted>
- , tag::weighted_peaks_over_threshold<LeftRight>
- , tag::peaks_over_threshold<LeftRight>
- >::type
- peaks_over_threshold_tag;
- extractor<peaks_over_threshold_tag> const some_peaks_over_threshold = {};
- float_type u_bar = some_peaks_over_threshold(args).template get<0>();
- float_type beta_bar = some_peaks_over_threshold(args).template get<1>();
- float_type xi_hat = some_peaks_over_threshold(args).template get<2>();
- return this->sign_ * (u_bar + beta_bar/xi_hat * ( std::pow(
- is_same<LeftRight, left>::value ? args[quantile_probability] : 1. - args[quantile_probability]
- , -xi_hat
- ) - 1.));
- }
-
-
- template<class Archive>
- void serialize(Archive & ar, const unsigned int file_version)
- {
- ar & sign_;
- }
- private:
- short sign_;
- };
- }
- namespace tag
- {
- template<typename LeftRight>
- struct pot_quantile
- : depends_on<peaks_over_threshold<LeftRight> >
- {
-
-
- typedef accumulators::impl::pot_quantile_impl<mpl::_1, unweighted, LeftRight> impl;
- };
- template<typename LeftRight>
- struct pot_quantile_prob
- : depends_on<peaks_over_threshold_prob<LeftRight> >
- {
-
-
- typedef accumulators::impl::pot_quantile_impl<mpl::_1, unweighted, LeftRight> impl;
- };
- template<typename LeftRight>
- struct weighted_pot_quantile
- : depends_on<weighted_peaks_over_threshold<LeftRight> >
- {
-
-
- typedef accumulators::impl::pot_quantile_impl<mpl::_1, weighted, LeftRight> impl;
- };
- template<typename LeftRight>
- struct weighted_pot_quantile_prob
- : depends_on<weighted_peaks_over_threshold_prob<LeftRight> >
- {
-
-
- typedef accumulators::impl::pot_quantile_impl<mpl::_1, weighted, LeftRight> impl;
- };
- }
- template<typename LeftRight>
- struct as_feature<tag::pot_quantile<LeftRight>(with_threshold_value)>
- {
- typedef tag::pot_quantile<LeftRight> type;
- };
- template<typename LeftRight>
- struct as_feature<tag::pot_quantile<LeftRight>(with_threshold_probability)>
- {
- typedef tag::pot_quantile_prob<LeftRight> type;
- };
- template<typename LeftRight>
- struct as_feature<tag::weighted_pot_quantile<LeftRight>(with_threshold_value)>
- {
- typedef tag::weighted_pot_quantile<LeftRight> type;
- };
- template<typename LeftRight>
- struct as_feature<tag::weighted_pot_quantile<LeftRight>(with_threshold_probability)>
- {
- typedef tag::weighted_pot_quantile_prob<LeftRight> type;
- };
- template<typename LeftRight>
- struct feature_of<tag::pot_quantile<LeftRight> >
- : feature_of<tag::quantile>
- {
- };
- template<typename LeftRight>
- struct feature_of<tag::pot_quantile_prob<LeftRight> >
- : feature_of<tag::quantile>
- {
- };
- template<typename LeftRight>
- struct as_weighted_feature<tag::pot_quantile<LeftRight> >
- {
- typedef tag::weighted_pot_quantile<LeftRight> type;
- };
- template<typename LeftRight>
- struct feature_of<tag::weighted_pot_quantile<LeftRight> >
- : feature_of<tag::pot_quantile<LeftRight> >
- {
- };
- template<typename LeftRight>
- struct as_weighted_feature<tag::pot_quantile_prob<LeftRight> >
- {
- typedef tag::weighted_pot_quantile_prob<LeftRight> type;
- };
- template<typename LeftRight>
- struct feature_of<tag::weighted_pot_quantile_prob<LeftRight> >
- : feature_of<tag::pot_quantile_prob<LeftRight> >
- {
- };
- }}
- #endif
|