diff --git a/include/boost/accumulators/statistics/extended_p_square.hpp b/include/boost/accumulators/statistics/extended_p_square.hpp index e6cc8dc..ab9959f 100644 --- a/include/boost/accumulators/statistics/extended_p_square.hpp +++ b/include/boost/accumulators/statistics/extended_p_square.hpp @@ -10,6 +10,9 @@ #include #include +#include +#include +#include #include #include #include @@ -92,6 +95,16 @@ namespace impl , desired_positions(heights.size()) , positions_increments(heights.size()) { + BOOST_FOREACH(float_type p, this->probabilities) + { + if (p < 0 || p > 1) + { + std::ostringstream msg; + msg << "extended_p_square_probabilities = " << p << " is not valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + } + std::size_t num_quantiles = this->probabilities.size(); std::size_t num_markers = this->heights.size(); diff --git a/include/boost/accumulators/statistics/extended_p_square_quantile.hpp b/include/boost/accumulators/statistics/extended_p_square_quantile.hpp index a17843d..fb97533 100644 --- a/include/boost/accumulators/statistics/extended_p_square_quantile.hpp +++ b/include/boost/accumulators/statistics/extended_p_square_quantile.hpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include #include @@ -77,6 +79,15 @@ namespace impl , boost::end(args[extended_p_square_probabilities]) ) { + BOOST_FOREACH(float_type p, this->probabilities) + { + if (p < 0 || p > 1) + { + std::ostringstream msg; + msg << "extended_p_square_probabilities = " << p << " is not valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + } } template diff --git a/include/boost/accumulators/statistics/p_square_quantile.hpp b/include/boost/accumulators/statistics/p_square_quantile.hpp index 636fea7..c5efe3a 100644 --- a/include/boost/accumulators/statistics/p_square_quantile.hpp +++ b/include/boost/accumulators/statistics/p_square_quantile.hpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include #include @@ -67,6 +69,13 @@ namespace impl , desired_positions() , positions_increments() { + if (this->p < 0 || this->p > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << this->p << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + for(std::size_t i = 0; i < 5; ++i) { this->actual_positions[i] = i + 1.; diff --git a/include/boost/accumulators/statistics/peaks_over_threshold.hpp b/include/boost/accumulators/statistics/peaks_over_threshold.hpp index f04f743..a510be6 100644 --- a/include/boost/accumulators/statistics/peaks_over_threshold.hpp +++ b/include/boost/accumulators/statistics/peaks_over_threshold.hpp @@ -219,6 +219,12 @@ namespace impl , fit_parameters_(boost::make_tuple(0., 0., 0.)) , is_dirty_(true) { + if (this->threshold_probability_ < 0 || this->threshold_probability_ > 1) + { + std::ostringstream msg; + msg << "pot_threshold_probability = " << this->threshold_probability_ << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } } void operator ()(dont_care) diff --git a/include/boost/accumulators/statistics/pot_quantile.hpp b/include/boost/accumulators/statistics/pot_quantile.hpp index 470bdba..d831dd5 100644 --- a/include/boost/accumulators/statistics/pot_quantile.hpp +++ b/include/boost/accumulators/statistics/pot_quantile.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -61,6 +63,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + typedef typename mpl::if_< is_same diff --git a/include/boost/accumulators/statistics/pot_tail_mean.hpp b/include/boost/accumulators/statistics/pot_tail_mean.hpp index a78043f..86732c9 100644 --- a/include/boost/accumulators/statistics/pot_tail_mean.hpp +++ b/include/boost/accumulators/statistics/pot_tail_mean.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -64,6 +66,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + typedef typename mpl::if_< is_same diff --git a/include/boost/accumulators/statistics/tail_mean.hpp b/include/boost/accumulators/statistics/tail_mean.hpp index 67dae37..eb1aab7 100644 --- a/include/boost/accumulators/statistics/tail_mean.hpp +++ b/include/boost/accumulators/statistics/tail_mean.hpp @@ -71,6 +71,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + std::size_t cnt = count(args); std::size_t n = static_cast( diff --git a/include/boost/accumulators/statistics/tail_quantile.hpp b/include/boost/accumulators/statistics/tail_quantile.hpp index 9ff56b5..1f4a617 100644 --- a/include/boost/accumulators/statistics/tail_quantile.hpp +++ b/include/boost/accumulators/statistics/tail_quantile.hpp @@ -68,6 +68,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + std::size_t cnt = count(args); std::size_t n = static_cast( diff --git a/include/boost/accumulators/statistics/tail_variate_means.hpp b/include/boost/accumulators/statistics/tail_variate_means.hpp index d34d4ab..4c9bbdf 100644 --- a/include/boost/accumulators/statistics/tail_variate_means.hpp +++ b/include/boost/accumulators/statistics/tail_variate_means.hpp @@ -89,6 +89,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + std::size_t cnt = count(args); std::size_t n = static_cast( diff --git a/include/boost/accumulators/statistics/weighted_extended_p_square.hpp b/include/boost/accumulators/statistics/weighted_extended_p_square.hpp index ac857e0..6ba3484 100644 --- a/include/boost/accumulators/statistics/weighted_extended_p_square.hpp +++ b/include/boost/accumulators/statistics/weighted_extended_p_square.hpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include #include @@ -89,6 +91,15 @@ namespace impl , actual_positions(heights.size()) , desired_positions(heights.size()) { + BOOST_FOREACH(float_type p, this->probabilities) + { + if (p < 0 || p > 1) + { + std::ostringstream msg; + msg << "extended_p_square_probabilities = " << p << " is not valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + } } template diff --git a/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp b/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp index 2ebc7b1..f43ac4e 100644 --- a/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp +++ b/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -67,6 +69,12 @@ namespace impl { , actual_positions() , desired_positions() { + if (this->p < 0 || this->p > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << this->p << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } } template diff --git a/include/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp b/include/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp index 418b38c..79df0df 100644 --- a/include/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp +++ b/include/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp @@ -148,6 +148,12 @@ namespace impl , fit_parameters_(boost::make_tuple(0., 0., 0.)) , is_dirty_(true) { + if (this->threshold_probability_ < 0 || this->threshold_probability_ > 1) + { + std::ostringstream msg; + msg << "pot_threshold_probability = " << this->threshold_probability_ << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } } void operator ()(dont_care) diff --git a/include/boost/accumulators/statistics/weighted_tail_mean.hpp b/include/boost/accumulators/statistics/weighted_tail_mean.hpp index bae8530..e2a3fc6 100644 --- a/include/boost/accumulators/statistics/weighted_tail_mean.hpp +++ b/include/boost/accumulators/statistics/weighted_tail_mean.hpp @@ -91,6 +91,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + float_type threshold = sum_of_weights(args) * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); diff --git a/include/boost/accumulators/statistics/weighted_tail_quantile.hpp b/include/boost/accumulators/statistics/weighted_tail_quantile.hpp index b143457..407ce38 100644 --- a/include/boost/accumulators/statistics/weighted_tail_quantile.hpp +++ b/include/boost/accumulators/statistics/weighted_tail_quantile.hpp @@ -75,6 +75,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + float_type threshold = sum_of_weights(args) * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); diff --git a/include/boost/accumulators/statistics/weighted_tail_variate_means.hpp b/include/boost/accumulators/statistics/weighted_tail_variate_means.hpp index 2c90783..879ea7f 100644 --- a/include/boost/accumulators/statistics/weighted_tail_variate_means.hpp +++ b/include/boost/accumulators/statistics/weighted_tail_variate_means.hpp @@ -117,6 +117,13 @@ namespace impl template result_type result(Args const &args) const { + if (args[quantile_probability] < 0 || args[quantile_probability] > 1) + { + std::ostringstream msg; + msg << "quantile_probability = " << args[quantile_probability] << " is not in valid range [0, 1]"; + boost::throw_exception(std::logic_error(msg.str())); + } + float_type threshold = sum_of_weights(args) * ( ( is_same::value ) ? args[quantile_probability] : 1. - args[quantile_probability] );