Public Member Functions | Protected Attributes | List of all members
gnsstk::SeqStats< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::SeqStats< T >

Sequential conventional statistics for one sample; gives results identical to class Stats except there is no scaling. This class maintains a current average and variance with each Add(); thus it is more efficient when results at each step are accessed - use this class when stats are to be accessed often, e.g. after each Add(). Class Stats holds sum(x) and sum(x squared) and computes ave, sig etc on call. NB. class WtdStats (weighted stats) derives from this class.

Definition at line 388 of file Stats.hpp.

#include <Stats.hpp>

Inheritance diagram for gnsstk::SeqStats< T >:
Inheritance graph
[legend]

Public Member Functions

void Add (const T &x)
 
void Add (std::vector< T > &X)
 add a std::vector<T> of samples to the computation of statistics More...
 
void Add (Vector< T > &X)
 add a gnsstk::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 SeqStats 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 SeqStats to a single-line string. More...
 
Average (void) const
 return computed 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)
 
Maximum (void) const
 return maximum value More...
 
Minimum (void) const
 return minimum value More...
 
unsigned int N (void) const
 return the sample size More...
 
SeqStats< T > & operator+= (const SeqStats< T > &S)
 combine two SeqStats (assumed taken from the same or equivalent ensembles); More...
 
SeqStats< T > & operator-= (const SeqStats< T > &S)
 
void Reset (void)
 reset, i.e. ignore earlier data and restart sampling More...
 
 SeqStats ()
 constructor More...
 
 SeqStats (Vector< T > &X)
 constructor given a gnsstk::Vector<T> of data More...
 
StdDev (void) const
 return computed standard deviation More...
 
void Subtract (const T x)
 
void Subtract (std::vector< T > &X)
 
void Subtract (Vector< T > &X)
 
Variance (void) const
 return computed variance More...
 

Protected Attributes

ave
 Average value. More...
 
max
 Maximum value. More...
 
min
 Minimum value. More...
 
unsigned int n
 number of samples added to the statistics More...
 
var
 Variance (square of the standard deviation) More...
 

Constructor & Destructor Documentation

◆ SeqStats() [1/2]

template<class T >
gnsstk::SeqStats< T >::SeqStats ( )
inline

constructor

Definition at line 392 of file Stats.hpp.

◆ SeqStats() [2/2]

template<class T >
gnsstk::SeqStats< T >::SeqStats ( Vector< T > &  X)
inline

constructor given a gnsstk::Vector<T> of data

Definition at line 398 of file Stats.hpp.

Member Function Documentation

◆ Add() [1/3]

template<class T >
void gnsstk::SeqStats< T >::Add ( const T &  x)
inline

add a single sample to the computation of statistics) NB this is the fundamental Add routine; all other Add's call this

Definition at line 404 of file Stats.hpp.

◆ Add() [2/3]

template<class T >
void gnsstk::SeqStats< T >::Add ( std::vector< T > &  X)
inline

add a std::vector<T> of samples to the computation of statistics

Definition at line 443 of file Stats.hpp.

◆ Add() [3/3]

template<class T >
void gnsstk::SeqStats< T >::Add ( Vector< T > &  X)
inline

add a gnsstk::Vector<T> of samples to the computation of statistics

Definition at line 437 of file Stats.hpp.

◆ asShortString()

template<class T >
std::string gnsstk::SeqStats< T >::asShortString ( std::string  msg = std::string(),
int  w = 0,
int  p = 3 
) const
inline

Write SeqStats N,ave,sig to a short single-line string.

Definition at line 556 of file Stats.hpp.

◆ asString()

template<class T >
std::string gnsstk::SeqStats< T >::asString ( std::string  msg = std::string(),
int  w = 7,
int  p = 4 
) const
inline

Write SeqStats to a single-line string.

Definition at line 540 of file Stats.hpp.

◆ Average()

template<class T >
T gnsstk::SeqStats< T >::Average ( void  ) const
inline

return computed average

Definition at line 577 of file Stats.hpp.

◆ Dump()

template<class T >
void gnsstk::SeqStats< T >::Dump ( std::vector< unsigned int > &  vuint,
std::vector< T > &  vT 
)
inline

Dump SeqStats private members directly; useful in saving an object (e.g. to a file); reload with Load().

Parameters
vuintoutput vector<unsigned int> of length 1, input of Load()
vToutput vector<T> of length 4, input of Load()

Definition at line 507 of file Stats.hpp.

◆ Load()

template<class T >
void gnsstk::SeqStats< T >::Load ( const std::vector< unsigned int > &  vuint,
const std::vector< T > &  vT 
)
inline

Define SeqStats private members directly; useful in continuing with an object that was earlier saved (e.g. to a file) using Dump().

Parameters
vuintinput vector<unsigned int> of length 1, output of Dump()
vTinput vector<T> of length 4, output of Dump() NB no checking at all - caller has burden of validity NB zero-fill rather than throwing

Definition at line 523 of file Stats.hpp.

◆ Maximum()

template<class T >
T gnsstk::SeqStats< T >::Maximum ( void  ) const
inline

return maximum value

Definition at line 574 of file Stats.hpp.

◆ Minimum()

template<class T >
T gnsstk::SeqStats< T >::Minimum ( void  ) const
inline

return minimum value

Definition at line 571 of file Stats.hpp.

◆ N()

template<class T >
unsigned int gnsstk::SeqStats< T >::N ( void  ) const
inline

return the sample size

Definition at line 568 of file Stats.hpp.

◆ operator+=()

template<class T >
SeqStats<T>& gnsstk::SeqStats< T >::operator+= ( const SeqStats< T > &  S)
inline

combine two SeqStats (assumed taken from the same or equivalent ensembles);

Definition at line 467 of file Stats.hpp.

◆ operator-=()

template<class T >
SeqStats<T>& gnsstk::SeqStats< T >::operator-= ( const SeqStats< T > &  S)
inline

remove one SeqStats from another, assumed to be taken from the same or equivalent ensembles. NB. Assumes that these samples were previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 488 of file Stats.hpp.

◆ Reset()

template<class T >
void gnsstk::SeqStats< T >::Reset ( void  )
inline

reset, i.e. ignore earlier data and restart sampling

Definition at line 395 of file Stats.hpp.

◆ StdDev()

template<class T >
T gnsstk::SeqStats< T >::StdDev ( void  ) const
inline

return computed standard deviation

Definition at line 587 of file Stats.hpp.

◆ Subtract() [1/3]

template<class T >
void gnsstk::SeqStats< T >::Subtract ( const x)
inline

remove a sample from the computation of statistics NB this is the fundamental Subtract routine; all others call this NB. Assumes that this sample was previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 425 of file Stats.hpp.

◆ Subtract() [2/3]

template<class T >
void gnsstk::SeqStats< T >::Subtract ( std::vector< T > &  X)
inline

remove a std::vector<T> of samples to the computation of statistics NB. Assumes that these samples were previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 459 of file Stats.hpp.

◆ Subtract() [3/3]

template<class T >
void gnsstk::SeqStats< T >::Subtract ( Vector< T > &  X)
inline

remove a gnsstk::Vector<T> of samples to the computation of statistics NB. Assumes that these samples were previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 451 of file Stats.hpp.

◆ Variance()

template<class T >
T gnsstk::SeqStats< T >::Variance ( void  ) const
inline

return computed variance

Definition at line 580 of file Stats.hpp.

Member Data Documentation

◆ ave

template<class T >
T gnsstk::SeqStats< T >::ave
protected

Average value.

Definition at line 597 of file Stats.hpp.

◆ max

template<class T >
T gnsstk::SeqStats< T >::max
protected

Maximum value.

Definition at line 596 of file Stats.hpp.

◆ min

template<class T >
T gnsstk::SeqStats< T >::min
protected

Minimum value.

Definition at line 595 of file Stats.hpp.

◆ n

template<class T >
unsigned int gnsstk::SeqStats< T >::n
protected

number of samples added to the statistics

Definition at line 594 of file Stats.hpp.

◆ var

template<class T >
T gnsstk::SeqStats< T >::var
protected

Variance (square of the standard deviation)

Definition at line 598 of file Stats.hpp.


The documentation for this class was generated from the following file:


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:46