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

Detailed Description

template<class T>
class gnsstk::WtdStats< T >

Weighted conventional statistics for one sample. Derived from SeqStats<T> Weights must not be zero; zero weight causes the sample to be ignored.

Definition at line 620 of file Stats.hpp.

#include <Stats.hpp>

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

Public Member Functions

void Add (const T &x, const T &wt_in)
 
void Add (std::vector< T > &X, std::vector< T > &W)
 add a std::vector<T> of samples, with weights More...
 
void Add (Vector< T > &X, Vector< T > &W)
 add a gnsstk::Vector<T> of samples, with weights More...
 
std::string asShortString (std::string msg=std::string(), int w=0, int p=3) const
 Write WtdStats 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 WtdStats to a single-line string. More...
 
void Dump (std::vector< unsigned int > &vuint, std::vector< T > &vT)
 
void Load (std::vector< unsigned int > &vuint, std::vector< T > &vT)
 
WtdStats< T > & operator+= (const WtdStats< T > &S)
 combine two WtdStats (assumed taken from the same or equivalent ensembles); More...
 
WtdStats< T > & operator-= (const WtdStats< T > &S)
 
void Subtract (const T &x, const T &wt_in)
 
void Subtract (std::vector< T > &X, std::vector< T > &W)
 
void Subtract (Vector< T > &X, Vector< T > &W)
 
 WtdStats ()
 constructor More...
 
 WtdStats (Vector< T > &X, Vector< T > &W)
 constructor given a gnsstk::Vector<T> of data, with weights More...
 
WtsSum (void) const
 return normalization = sum of weights More...
 
- Public Member Functions inherited from gnsstk::SeqStats< T >
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

WtNorm
 Normalization constant = sum weights. More...
 
- Protected Attributes inherited from gnsstk::SeqStats< T >
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

◆ WtdStats() [1/2]

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

constructor

Definition at line 624 of file Stats.hpp.

◆ WtdStats() [2/2]

template<class T >
gnsstk::WtdStats< T >::WtdStats ( Vector< T > &  X,
Vector< T > &  W 
)
inline

constructor given a gnsstk::Vector<T> of data, with weights

Definition at line 627 of file Stats.hpp.

Member Function Documentation

◆ Add() [1/3]

template<class T >
void gnsstk::WtdStats< T >::Add ( const T &  x,
const T &  wt_in 
)
inline

add a single sample to the computation of statistics NB this is the fundamental Add routine; all other Add's call this NB input of zero weight causes the sample x to be ignored.

Definition at line 638 of file Stats.hpp.

◆ Add() [2/3]

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

add a std::vector<T> of samples, with weights

Definition at line 690 of file Stats.hpp.

◆ Add() [3/3]

template<class T >
void gnsstk::WtdStats< T >::Add ( Vector< T > &  X,
Vector< T > &  W 
)
inline

add a gnsstk::Vector<T> of samples, with weights

Definition at line 683 of file Stats.hpp.

◆ asShortString()

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

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

Definition at line 812 of file Stats.hpp.

◆ asString()

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

Write WtdStats to a single-line string.

Definition at line 794 of file Stats.hpp.

◆ Dump()

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

Dump WtdStats 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 5, input of Load()

Definition at line 767 of file Stats.hpp.

◆ Load()

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

Define WtdStats 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 5, output of Dump() NB no checking at all - caller has burden of validity NB zero-fill rather than throwing

Definition at line 779 of file Stats.hpp.

◆ operator+=()

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

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

Definition at line 719 of file Stats.hpp.

◆ operator-=()

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

remove one WtdStats from another, assumed to be taken from the same or equivalent ensembles. NB. Assumes that this sample was previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 745 of file Stats.hpp.

◆ Subtract() [1/3]

template<class T >
void gnsstk::WtdStats< T >::Subtract ( const T &  x,
const T &  wt_in 
)
inline

remove a sample from the computation of statistics NB input of zero weight causes the sample x to be ignored. 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 667 of file Stats.hpp.

◆ Subtract() [2/3]

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

remove a std::vector<T> of samples, with weights NB input of zero weight causes the sample x to be ignored. NB. Assumes that this sample was previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 710 of file Stats.hpp.

◆ Subtract() [3/3]

template<class T >
void gnsstk::WtdStats< T >::Subtract ( Vector< T > &  X,
Vector< T > &  W 
)
inline

remove a gnsstk::Vector<T> of samples, with weights NB input of zero weight causes the sample x to be ignored. NB. Assumes that this sample was previously added. NB. Minimum() and Maximum() may no longer be valid.

Definition at line 700 of file Stats.hpp.

◆ WtsSum()

template<class T >
T gnsstk::WtdStats< T >::WtsSum ( void  ) const
inline

return normalization = sum of weights

Definition at line 823 of file Stats.hpp.

Member Data Documentation

◆ WtNorm

template<class T >
T gnsstk::WtdStats< T >::WtNorm
protected

Normalization constant = sum weights.

Definition at line 826 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