3 // Copyright (C) 1999 Allen Akin All Rights Reserved.
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
32 // stats.h: simple statistics-gathering utilities for glean
34 // These are rather simplistic. For more robust implementations, consider
35 // using Numerical Recipes.
46 #if defined( __WIN__ )
63 inline int n() const {return _n
;}
64 inline double min() const {return _min
;}
65 inline double max() const {return _max
;}
66 inline double sum() const {return _sum
;}
67 inline double sum2() const {return _sum2
;}
69 double variance() const;
70 double deviation() const;
71 inline void sample(double d
) {
81 BasicStats() {init();}
82 template<class T
> BasicStats(std::vector
<T
>& v
) {
84 for (typename
std::vector
<T
>::const_iterator p
= v
.begin(); p
< v
.end(); ++p
)
87 }; // class BasicStats