Disaggregate
Disaggregate Smart Meter data

Statistic< T > Struct Template Reference

#include <Statistic.h>

Inheritance diagram for Statistic< T >:
Collaboration diagram for Statistic< T >:

List of all members.

Public Member Functions

 Statistic ()
 Default constructor.
 Statistic (const T value)
 Constructor from a single value. 'Fakes' a standard deviation.
 Statistic (const Histogram &data, const size_t beginning=0, size_t end=std::numeric_limits< std::size_t >::max())
 Constructor from histogram data.
 Statistic (const Array< T > &data, const size_t beginning=0, size_t end=std::numeric_limits< std::size_t >::max())
 Constructor from array data (NOT histograms)
void update (const Array< T > &data, const size_t beginning=0, size_t end=std::numeric_limits< std::size_t >::max(), const bool checkForOutliers=false)
 Update an existing Statistic with new data points.
void update (const Statistic< T > &otherStat)
 Update an existing Statistic with data from an existing statistic.
const double calcStdev () const
void update (const T datum)
 Update an existing Statistic with a single new data point.
const bool similar (const Statistic< T > other, const double alpha=0.05) const
 Uses a two-sided Student T-Test to determine if other.mean is 'similar' to the calling object's mean.
const double tTest (const Statistic< T > other) const
 A two-sided Student T-Test.
const double nonZeroStdev () const
 Returns stdev if stdev > mean/10, else returns mean/10.
const double normalisedLikelihood (const double x) const
 The likelihood is normalised by dividing the raw likelihood by the likelihood of the distribution's mean. The end result is that we get a number between 0 and 1 which tells us how close we are to the distribution's mean; if we're right on target then the normalised likelihood will be 1.
void outputStateBarsLine (std::ostream &o) const
const double getMean () const
const double getStdev () const
const T getMin () const
const T getMax () const
const size_t getNumDataPoints () const

Public Attributes

double mean
double stdev
min
max
size_t numDataPoints
std::list< T > dataStore
 store every data point we've ever seen so we can re-calculate an accurate stdev on every update.

Friends

std::ostream & operator<< (std::ostream &o, const Statistic< T > &s)

Detailed Description

template<class T>
struct Statistic< T >

Definition at line 24 of file Statistic.h.


Constructor & Destructor Documentation

template<class T>
Statistic< T >::Statistic ( ) [inline]

Default constructor.

Definition at line 46 of file Statistic.h.

template<class T>
Statistic< T >::Statistic ( const T  value) [inline]

Constructor from a single value. 'Fakes' a standard deviation.

Definition at line 53 of file Statistic.h.

template<class T>
Statistic< T >::Statistic ( const Histogram data,
const size_t  beginning = 0,
size_t  end = std::numeric_limits<std::size_t>::max() 
) [inline]

Constructor from histogram data.

Parameters:
datadata
beginningbeginning (gets included in stats)
endend (excluded from stats)

Definition at line 65 of file Statistic.h.

template<class T>
Statistic< T >::Statistic ( const Array< T > &  data,
const size_t  beginning = 0,
size_t  end = std::numeric_limits<std::size_t>::max() 
) [inline]

Constructor from array data (NOT histograms)

Definition at line 109 of file Statistic.h.


Member Function Documentation

template<class T>
const double Statistic< T >::calcStdev ( ) const [inline]

Definition at line 253 of file Statistic.h.

Referenced by Statistic< Sample_t >::Statistic(), and Statistic< Sample_t >::update().

Here is the caller graph for this function:

template<class T>
const T Statistic< T >::getMax ( ) const [inline]

Definition at line 419 of file Statistic.h.

template<class T>
const double Statistic< T >::getMean ( ) const [inline]

Definition at line 416 of file Statistic.h.

template<class T>
const T Statistic< T >::getMin ( ) const [inline]

Definition at line 418 of file Statistic.h.

template<class T>
const size_t Statistic< T >::getNumDataPoints ( ) const [inline]

Definition at line 420 of file Statistic.h.

template<class T>
const double Statistic< T >::getStdev ( ) const [inline]

Definition at line 417 of file Statistic.h.

template<class T>
const double Statistic< T >::nonZeroStdev ( ) const [inline]

Returns stdev if stdev > mean/10, else returns mean/10.

Definition at line 369 of file Statistic.h.

Referenced by AggregateData::findSpike(), Statistic< Sample_t >::normalisedLikelihood(), and Statistic< Sample_t >::tTest().

Here is the caller graph for this function:

template<class T>
const double Statistic< T >::normalisedLikelihood ( const double  x) const [inline]

The likelihood is normalised by dividing the raw likelihood by the likelihood of the distribution's mean. The end result is that we get a number between 0 and 1 which tells us how close we are to the distribution's mean; if we're right on target then the normalised likelihood will be 1.

Definition at line 383 of file Statistic.h.

Referenced by PowerStateGraph::findBestPath(), and AggregateData::findSpike().

Here is the caller graph for this function:

template<class T>
void Statistic< T >::outputStateBarsLine ( std::ostream &  o) const [inline]

Definition at line 410 of file Statistic.h.

template<class T>
const bool Statistic< T >::similar ( const Statistic< T >  other,
const double  alpha = 0.05 
) const [inline]

Uses a two-sided Student T-Test to determine if other.mean is 'similar' to the calling object's mean.

Returns:
true if other is 'similar' to calling object.
Parameters:
alphasignificance level

Definition at line 300 of file Statistic.h.

template<class T>
const double Statistic< T >::tTest ( const Statistic< T >  other) const [inline]

A two-sided Student T-Test.

Uses a Chi-Squared test for equal variances first.

Code adapted from boost tutorial on Comparing the means of two samples with the Students-t test

Returns:
complement of probability (the probability that the difference is due to chance). i.e. the higher this value, the more likely the two distributions have similar means.

Definition at line 325 of file Statistic.h.

Referenced by PowerStateGraph::mostSimilarVertex(), and Statistic< Sample_t >::similar().

Here is the caller graph for this function:

template<class T>
void Statistic< T >::update ( const T  datum) [inline]

Update an existing Statistic with a single new data point.

Update the sample standard deviation with the new data.

Definition at line 270 of file Statistic.h.

template<class T>
void Statistic< T >::update ( const Statistic< T > &  otherStat) [inline]

Update an existing Statistic with data from an existing statistic.

Definition at line 237 of file Statistic.h.

template<class T>
void Statistic< T >::update ( const Array< T > &  data,
const size_t  beginning = 0,
size_t  end = std::numeric_limits<std::size_t>::max(),
const bool  checkForOutliers = false 
) [inline]

Update an existing Statistic with new data points.

Update the sample standard deviation with the new data.

Definition at line 167 of file Statistic.h.

Referenced by Statistic< Sample_t >::update(), and PowerStateGraph::update().

Here is the caller graph for this function:


Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  o,
const Statistic< T > &  s 
) [friend]

Definition at line 396 of file Statistic.h.


Member Data Documentation

template<class T>
std::list<T> Statistic< T >::dataStore

store every data point we've ever seen so we can re-calculate an accurate stdev on every update.

Memory-hungry but accurate. DOES NOT WORK with histogram data.

Definition at line 34 of file Statistic.h.

Referenced by Statistic< Sample_t >::calcStdev(), Statistic< Sample_t >::Statistic(), and Statistic< Sample_t >::update().


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends