1 // (C) Copyright John Maddock 2005-2006.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_MATH_TOOLS_STATS_INCLUDED
7 #define BOOST_MATH_TOOLS_STATS_INCLUDED
13 #include <boost/config/no_tr1/cmath.hpp>
14 #include <boost/cstdint.hpp>
15 #include <boost/math/tools/precision.hpp>
17 namespace boost{ namespace math{ namespace tools{
24 : m_min(tools::max_value<T>()),
25 m_max(-tools::max_value<T>()),
30 void add(const T& val)
38 m_squared_total += val*val;
40 T min BOOST_PREVENT_MACRO_SUBSTITUTION()const{ return m_min; }
41 T max BOOST_PREVENT_MACRO_SUBSTITUTION()const{ return m_max; }
42 T total()const{ return m_total; }
43 T mean()const{ return m_total / static_cast<T>(m_count); }
44 boost::uintmax_t count()const{ return m_count; }
49 T t = m_squared_total - m_total * m_total / m_count;
57 T t = m_squared_total - m_total * m_total / m_count;
65 return sqrt(m_squared_total / static_cast<T>(m_count));
67 stats& operator+=(const stats& s)
74 m_squared_total += s.m_squared_total;
79 T m_min, m_max, m_total, m_squared_total;
80 boost::uintmax_t m_count;