![]() |
General Utility Library for C++17 26.5.0
|
Declaration of statistical utility functions and classes.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <algorithm>#include <cmath>#include <limits>#include <numeric>#include <type_traits>#include <vector>#include "gul17/internal.h"#include "gul17/traits.h"

Go to the source code of this file.
Classes | |
| struct | gul17::MinMax< DataT, typename, typename > |
| Object that is designed to holds two values: minimum and maximum of something. More... | |
| class | gul17::StandardDeviationMean< DataT, typename > |
| A struct holding a standard deviation and a mean value. More... | |
Namespaces | |
| namespace | gul17 |
| Namespace gul17 contains all functions and classes of the General Utility Library. | |
Typedefs | |
| using | gul17::statistics_result_type = double |
| Type used to return statistic properties. | |
Functions | |
| template<typename ElementT > | |
| auto | gul17::ElementAccessor () |
| Return a mock element accessor for containers. | |
| template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::mean (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| Calculate the arithmetic mean value of all elements in a container. | |
| template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::rms (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| Calculate the root mean square of all elements in a container. | |
| template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::median (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| Find the median of all elements in a container. | |
| template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::maximum (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> DataT |
| Return the maximum element value in a container. | |
| template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::minimum (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> DataT |
| Return the minimum element value in a container. | |
| template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::min_max (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> MinMax< DataT > |
| Find the minimum and maximum element values in a container. | |
| template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::remove_outliers (ContainerT &&cont, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> ContainerT & |
| Remove elements that are far away from other elements. | |
| template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::remove_outliers (ContainerT const &cont, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> std::vector< ElementT > |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The original container is not modified. | |
| template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::standard_deviation (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> StandardDeviationMean< ResultT > |
| Calculate the standard deviation of all elements in a container. | |
| template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = typename std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename OpClosure , typename = std::enable_if_t<IsContainerLike<ContainerT>::value>> | |
| auto | gul17::accumulate (ContainerT const &container, OpClosure op, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| Calculate some aggregate value from all elements of a container. | |
| template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::mean (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::rms (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::median (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::maximum (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> DataT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::minimum (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> DataT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::min_max (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> MinMax< DataT > |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::remove_outliers (IteratorT const &begin, IteratorT const &end, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> std::vector< ElementT > |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The original container is not modified. | |
| template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>> | |
| auto | gul17::standard_deviation (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> StandardDeviationMean< ResultT > |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::invoke_result_t<decltype(ElementAccessor<ElementT>()), ElementT>(*)(ElementT const&), typename DataT = std::decay_t<std::invoke_result_t<Accessor, ElementT>>, typename OpClosure > | |
| auto | gul17::accumulate (IteratorT const &begin, IteratorT const &end, OpClosure op, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |