Conventional statistics for one sample, with scaling to improve numerical error in cases of very large numbers. Constructor does the same as Reset(); use it when starting a new series of input samples. Results are available at any time by calling N(), Minimum(), Maximum(), Average(), Variance() and StdDev(). Also the scale is available in Scale(). NB. Variance is normalized with 1/(N-1) and StdDev is sqrt(Variance). NB. This class is not intended to be used with non-floating types, for which it may yield incorrect results.
#include <Stats.hpp>
Public Member Functions | |
void | Add (const T &x) |
void | Add (const Vector< T > &X) |
Add gnsstk::Vector<T> of data to the statistics. More... | |
void | Add (std::vector< T > &X) |
add a std::vector<T> of samples to the computation of statistics More... | |
std::string | asShortString (std::string msg=std::string(), int w=0, int p=3) const |
Write Stats N,ave,sig to a short single-line string. More... | |
std::string | asString (std::string msg=std::string(), int w=7, int p=4) const |
Write Stats to a single-line string. More... | |
T | Average (void) const |
return the average More... | |
void | Dump (std::vector< unsigned int > &vuint, std::vector< T > &vT) |
void | Load (const std::vector< unsigned int > &vuint, const std::vector< T > &vT) |
T | Maximum (void) const |
return maximum value More... | |
T | Minimum (void) const |
return minimum value More... | |
unsigned int | N (void) const |
return the sample size More... | |
Stats< T > & | operator+= (const Stats< T > &S) |
combine two Stats (assumed taken from the same or equivalent ensembles) More... | |
Stats< T > & | operator-= (const Stats< T > &S) |
void | Reset (void) |
reset, i.e. ignore earlier data and restart sampling More... | |
T | Scale (void) const |
return the scale More... | |
Stats () | |
constructor More... | |
T | StdDev (void) const |
return computed standard deviation More... | |
void | Subtract (const T &x) |
void | Subtract (const Vector< T > &X) |
void | Subtract (std::vector< T > &X) |
T | Variance (void) const |
return computed variance More... | |
Protected Attributes | |
T | max |
Maximum value. More... | |
T | min |
Minimum value. More... | |
unsigned int | n |
number of samples added to the statistics More... | |
T | scale |
scale More... | |
bool | setScale |
scale has been set to non-zero More... | |
T | sum |
sum of x More... | |
T | sum2 |
sum of x squared More... | |
Friends | |
class | TwoSampleStats< T > |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Define Stats private members directly; useful in continuing with an object that was earlier saved (e.g. to a file) using Dump().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |