#include <Sequence/descriptiveStats.hpp>
Public Types | |
|
typedef ensureFloating< T, T > ::type | floating_type |
Public Member Functions | |
| BOOST_STATIC_ASSERT ((boost::is_convertible< T, floating_type >::value)) | |
| Sums< T > & | operator+= (const T &) |
| Sums< T > & | operator+= (const Sums< T > &) |
| const T & | sum () const |
| const T & | sumSquares () const |
| floating_type | mean () const |
| floating_type | variance () const |
A class to keep track of the sum, and sum of squares, of values. I wrote it to make it easier to calculate the means and variances.
Examples:
//example illustrates use of += and using std::accumulate Sequence::Sums<unsigned> s1; std::vector<unsigned> vd; int i = 0; while( i++ < 100 ) { unsigned r = random; s1 += r; vd.push_back(r); } Sequence::Sums<double> s2 = std::accumulate(vd.begin(),vd.end(),Sequence::Sums<double>()); std::cout << s1.mean() << '\t' << s2.mean() << '\n' << s1.variance() << '\t' << s2.variance() << '\n';
Definition at line 95 of file descriptiveStats.hpp.
1.6.3