Statistics Class Reference

#include <Statistics.h>

List of all members.

Public Member Functions

 Statistics (unsigned int maxAcfOrder, bool useExactCalculation=true)
void nextSample (double value)
unsigned long getNum () const
double getMean () const
double getVariance () const
double getAcf (unsigned int lag) const
bool isIidAcf () const
bool isIidTurningPoint () const
bool isIidDifferenceSign () const
bool isIid () const
unsigned int getMaModelOrder () const

Static Public Member Functions

static void testIncrementalAcf (unsigned int maxAcfOrder, double *values, unsigned int len, double accuracy)


Detailed Description

This class can be used to compute statistics on a _single_, numerical continuous variable. All computations are performance incrementally with runtime performance in mind.


Constructor & Destructor Documentation

Statistics::Statistics unsigned int  maxAcfOrder,
bool  useExactCalculation = true
 

If useExactCalculation is true, the autocorrellation values will be exact. If set to false, an approximation is used, which should be good enough until lag at about 10, and the object will only use 2/3 of the memory on the heap (2*sizeof(double)*maxAcfOrder instead of 3*sizeof(double)*maxAcfOrder). Please be aware that even with useExactCalculation, the ACF will still be off a bit, but at least be exact to an accuracy of 10^-3 until lag 128.

Setting maxAcfOrder to 0 will disable computation of the ACF and thus reduce the runtime complexity of nextSample significantly.


Member Function Documentation

double Statistics::getAcf unsigned int  lag  )  const
 

The (sample) autocorrelation of all samples values at the given lag.

This function thus represents the (sample) autocorrelation function (ACF). Please see "Introduction to Time Series and Forecasting", page 59 for details.

unsigned int Statistics::getMaModelOrder  )  const
 

Try to estimate the order q of an MA(q) model, under the proposition that the time series indeed can be expressed by an MA model.

This method basically returns the highest lag for which the sample ACF value (computed with getAcf(lag) is greater than +-1.96/sqrt(getNum()). It is an implementation of the method described in "Introduction to Time Series and Forecasting", page 94.

Returns:
The estimated order of an MA model, at maximum the value of maxAcfOrder specified in the constructor (which can also be 0 if the ACF calculation was disabled in that way).
See also:
getAcf

double Statistics::getMean  )  const
 

The (sample) mean of all sample values.

unsigned long Statistics::getNum  )  const
 

The number of samples.

double Statistics::getVariance  )  const
 

The (sample) variance of all sample values.

bool Statistics::isIid  )  const
 

Test the time series if it can be regarded as iid noise - independent and identically distributed random variables.

This test combines all implemented specific tests.

Returns:
true if the sequence is iid according to the all tests (none returned false), false otherwise.

bool Statistics::isIidAcf  )  const
 

Test the time series if it can be regarded as iid noise - independent and identically distributed random variables.

This method uses the sample autocorrelation function (whose values are available with getAcf) and checks if all values are within the bounds +-1.96/sqrt(getNum()). This corresponds to a probability of 95% that the sequence is iid according to this test.

Returns:
true if all values are within the bounds, false otherwise.

bool Statistics::isIidDifferenceSign  )  const
 

Test the time series if it can be regarded as iid noise - independent and identically distributed random variables.

This method uses the difference sign test, described in "Introduction to Time Series and Forecasting", page 37f.

If this test returns with false, it indicates the presence of an increasing (or decreasing) trend in the data.

Returns:
true if the sequence is iid according to the test, false otherwise.

bool Statistics::isIidTurningPoint  )  const
 

Test the time series if it can be regarded as iid noise - independent and identically distributed random variables.

This method uses the turning point test, described in "Introduction to Time Series and Forecasting", page 36f.

Returns:
true if the sequence is iid according to the test, false otherwise.

void Statistics::nextSample double  value  ) 
 

Update the internal helper variables with a new sample.

void Statistics::testIncrementalAcf unsigned int  maxAcfOrder,
double *  values,
unsigned int  len,
double  accuracy
[static]
 

This can be used for validating the computed ACF values.


The documentation for this class was generated from the following files:
Generated on Mon Jun 5 10:20:50 2006 for Intelligence.kdevelop by  doxygen 1.4.6