Disaggregate
Disaggregate Smart Meter data
|
#include <Statistic.h>
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 |
T | min |
T | 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) |
Definition at line 24 of file Statistic.h.
Default constructor.
Definition at line 46 of file Statistic.h.
Constructor from a single value. 'Fakes' a standard deviation.
Definition at line 53 of file Statistic.h.
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.
data | data |
beginning | beginning (gets included in stats) |
end | end (excluded from stats) |
Definition at line 65 of file Statistic.h.
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.
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().
const T Statistic< T >::getMax | ( | ) | const [inline] |
Definition at line 419 of file Statistic.h.
const double Statistic< T >::getMean | ( | ) | const [inline] |
Definition at line 416 of file Statistic.h.
const T Statistic< T >::getMin | ( | ) | const [inline] |
Definition at line 418 of file Statistic.h.
Definition at line 420 of file Statistic.h.
const double Statistic< T >::getStdev | ( | ) | const [inline] |
Definition at line 417 of file Statistic.h.
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().
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().
void Statistic< T >::outputStateBarsLine | ( | std::ostream & | o | ) | const [inline] |
Definition at line 410 of file Statistic.h.
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.
other
is 'similar' to calling object. alpha | significance level |
Definition at line 300 of file Statistic.h.
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
Definition at line 325 of file Statistic.h.
Referenced by PowerStateGraph::mostSimilarVertex(), and Statistic< Sample_t >::similar().
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.
Update an existing Statistic with data from an existing statistic.
Definition at line 237 of file Statistic.h.
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().
std::ostream& operator<< | ( | std::ostream & | o, |
const Statistic< T > & | s | ||
) | [friend] |
Definition at line 396 of file Statistic.h.
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().
Definition at line 31 of file Statistic.h.
Referenced by AggregateData::findSpike(), Statistic< Sample_t >::getMax(), Statistic< Sample_t >::outputStateBarsLine(), Statistic< Sample_t >::Statistic(), and Statistic< Sample_t >::update().
Definition at line 28 of file Statistic.h.
Referenced by Statistic< Sample_t >::calcStdev(), PowerStateGraph::disaggregate(), AggregateData::findSpike(), Statistic< Sample_t >::getMean(), PowerStateGraph::mostSimilarVertex(), Statistic< Sample_t >::nonZeroStdev(), Statistic< Sample_t >::normalisedLikelihood(), Statistic< Sample_t >::outputStateBarsLine(), PowerStateGraph::rejectSpike(), Statistic< Sample_t >::similar(), Statistic< Sample_t >::Statistic(), Device::trainPowerStateGraph(), Statistic< Sample_t >::tTest(), and Statistic< Sample_t >::update().
Definition at line 30 of file Statistic.h.
Referenced by AggregateData::findSpike(), Statistic< Sample_t >::getMin(), Statistic< Sample_t >::outputStateBarsLine(), AggregateData::readingGoesBelowPowerState(), Statistic< Sample_t >::Statistic(), and Statistic< Sample_t >::update().
size_t Statistic< T >::numDataPoints |
Definition at line 32 of file Statistic.h.
Referenced by Statistic< Sample_t >::calcStdev(), Statistic< Sample_t >::getNumDataPoints(), Statistic< Sample_t >::similar(), Statistic< Sample_t >::Statistic(), Statistic< Sample_t >::tTest(), Statistic< Sample_t >::update(), and Signature::updatePowerStates().
Definition at line 29 of file Statistic.h.
Referenced by AggregateData::findSpike(), Statistic< Sample_t >::getStdev(), Statistic< Sample_t >::nonZeroStdev(), PowerStateGraph::rejectSpike(), Statistic< Sample_t >::Statistic(), and Statistic< Sample_t >::update().