nidas v1.2.3
|
Adaptive forecaster for despiking of time-series data. More...
#include <AdaptiveDespiker.h>
Public Member Functions | |
AdaptiveDespiker () | |
Constructor. | |
void | setOutlierProbability (float val) |
float | getOutlierProbability () const |
void | setDiscLevelMultiplier (float val) |
float | getDiscLevelMultiplier () const |
float | getDiscLevel () const |
If a value is more than discrLevel * sigma away from the mean, then it is considered a spike, i.e. | |
float | despike (float u, bool *spike) |
Pass a value u, and return a forecasted value, along with a boolean indicating whether AdaptiveDespiker considers it a spike. | |
float | forecast () const |
Forecast a value based on the previous point and correlation and mean. | |
void | reset () |
Reset the statistics. | |
Static Public Member Functions | |
static float | discrLevel (float prob) |
Compute a discrimination level from a Gaussan probability. | |
static float | adjustLevel (float corr) |
Adjust the discrimination level based on the current correlation. | |
Private Member Functions | |
void | initStatistics (float u) |
void | incrementStatistics (float u) |
void | updateStatistics (float u) |
Static Private Member Functions | |
static bool | staticInit () |
static void | spline (float *x, float *y, int n, double yp1, double ypn, float *y2) |
Copied from "Numerical Recipies in C", the only changes being arrays are indexed from 0, due to personal taste, and doubles are passed instead of floats. | |
static double | splint (float *xa, float *ya, float *y2a, int n, double x) |
Private Attributes | |
float | _prob |
Prob for detection of outlier in good Gaussian data. | |
float | _levelMultiplier |
Increase detection level with this factor. | |
float | _maxMissingFreq |
If more than _maxMissingFreq of the recent 10 data points are missing data points, don't substitute forecasted data or update forecast statistics. | |
float | _u1 |
Last point. | |
double | _mean1 |
Previous mean. | |
double | _mean2 |
Current mean. | |
double | _var1 |
Previous variance. | |
double | _var2 |
Current variance. | |
double | _corr |
Correlation. | |
double | _initLevel |
Discrimination level. | |
double | _level |
float | _missfreq |
Running ave of freq of missing data. | |
int | _msize |
Memory size. | |
size_t | _npts |
Number of points processed. | |
Static Private Attributes | |
static const size_t | STATISTICS_SIZE = 100 |
static const int | ADJUST_TABLE_SIZE = 100 |
static const int | LEN_ERFC_ARRAY = 140 |
static float | _adj [ADJUST_TABLE_SIZE][2] |
static bool | staticInitDone = AdaptiveDespiker::staticInit() |
Adaptive forecaster for despiking of time-series data.
Algorithim taken from "A Statistical Data Screening Procedure" by Jorgen Hojstrup, Dept of Meteorology and Wind Energy, RISO National Laboratory, Denmark. [Published as: Meas. Sci. Technol (UK). v4 (1993) p. 153-157]
AdaptiveDespiker::AdaptiveDespiker | ( | ) |
Constructor.
References setDiscLevelMultiplier(), and setOutlierProbability().
Adjust the discrimination level based on the current correlation.
References _adj, ADJUST_TABLE_SIZE, and nidas::core::getSample().
Referenced by incrementStatistics(), and updateStatistics().
Pass a value u, and return a forecasted value, along with a boolean indicating whether AdaptiveDespiker considers it a spike.
The input value is added to the AdaptiveDespiker statistics for forecasting.
References _level, _maxMissingFreq, _missfreq, _npts, _var2, forecast(), nidas::core::getSample(), incrementStatistics(), initStatistics(), STATISTICS_SIZE, and updateStatistics().
Compute a discrimination level from a Gaussan probability.
If a value is more than discrLevel * sigma away from the mean, then it is considered a spike, i.e. it's probability exceeded the given value.
References nidas::core::getSample(), and LEN_ERFC_ARRAY.
Referenced by setDiscLevelMultiplier(), and setOutlierProbability().
|
inline |
|
inline |
If a value is more than discrLevel * sigma away from the mean, then it is considered a spike, i.e.
it's probability exceeded getOutlierProbability().
References _level.
Referenced by nidas::dynld::isff::Wind3D::getDiscLevel().
|
inline |
References _levelMultiplier.
Referenced by nidas::dynld::isff::Wind3D::getDiscLevelMultiplier().
|
inline |
References _prob.
Referenced by nidas::dynld::isff::Wind3D::getOutlierProbability().
References _corr, _initLevel, _level, _mean1, _mean2, _missfreq, _msize, _npts, _u1, _var1, _var2, adjustLevel(), nidas::core::getSample(), and STATISTICS_SIZE.
Referenced by despike().
void AdaptiveDespiker::reset | ( | ) |
Reset the statistics.
References _initLevel, _level, _missfreq, and _npts.
val | Discrimination level fudge factor. The computation of discrimination level from the Gaussian probability is typically too small and one can multiply the resultant level by this factor. We've typically used 2.5 in practice. |
References _initLevel, _level, _levelMultiplier, _prob, discrLevel(), and nidas::core::getSample().
Referenced by AdaptiveDespiker().
val | Probability of an outlier. This is converted to a discrimination level based on a Gaussian distribution. |
References _initLevel, _level, _levelMultiplier, _prob, discrLevel(), and nidas::core::getSample().
Referenced by AdaptiveDespiker().
|
staticprivate |
Copied from "Numerical Recipies in C", the only changes being arrays are indexed from 0, due to personal taste, and doubles are passed instead of floats.
Given arrays a[0..n-1] and y[0..n-1] containing a tabulated function, i.e. yi = f(xi), with x1 < x2 < ... < xn-1 and given values yp1 and ypn for the first derivative of the interpolating function at points 1 and n-1 respectively, this routine returns an array y2[0..n-1] that contains the second derivatives of the interpolatimng function at the tabulated points xi. If yp1 and/or ypn are equal to 1.e30 or larger, the routine is signalled to set the corresponding boundary condition for a natural spline, with zero second derivative at that boundary.
References nidas::core::getSample().
Referenced by staticInit().
|
staticprivate |
References _adj, ADJUST_TABLE_SIZE, nidas::core::getSample(), spline(), and splint().
References _corr, _initLevel, _level, _mean1, _mean2, _missfreq, _msize, _npts, _u1, _var1, _var2, adjustLevel(), and nidas::core::getSample().
Referenced by despike().
|
staticprivate |
Referenced by adjustLevel(), and staticInit().
|
private |
Correlation.
Referenced by forecast(), incrementStatistics(), initStatistics(), and updateStatistics().
|
private |
Discrimination level.
Referenced by incrementStatistics(), reset(), setDiscLevelMultiplier(), setOutlierProbability(), and updateStatistics().
|
private |
Referenced by despike(), getDiscLevel(), incrementStatistics(), reset(), setDiscLevelMultiplier(), setOutlierProbability(), and updateStatistics().
|
private |
Increase detection level with this factor.
Referenced by getDiscLevelMultiplier(), setDiscLevelMultiplier(), and setOutlierProbability().
|
private |
If more than _maxMissingFreq of the recent 10 data points are missing data points, don't substitute forecasted data or update forecast statistics.
Referenced by despike().
|
private |
Previous mean.
Referenced by incrementStatistics(), initStatistics(), and updateStatistics().
|
private |
Current mean.
Referenced by forecast(), incrementStatistics(), initStatistics(), and updateStatistics().
|
private |
Running ave of freq of missing data.
Referenced by despike(), incrementStatistics(), initStatistics(), reset(), and updateStatistics().
|
private |
Memory size.
Referenced by incrementStatistics(), and updateStatistics().
|
private |
Number of points processed.
Referenced by despike(), incrementStatistics(), initStatistics(), reset(), and updateStatistics().
|
private |
Prob for detection of outlier in good Gaussian data.
Referenced by getOutlierProbability(), setDiscLevelMultiplier(), and setOutlierProbability().
|
private |
Last point.
Referenced by forecast(), incrementStatistics(), initStatistics(), and updateStatistics().
|
private |
Previous variance.
Referenced by incrementStatistics(), initStatistics(), and updateStatistics().
|
private |
Current variance.
Referenced by despike(), incrementStatistics(), initStatistics(), and updateStatistics().
Referenced by adjustLevel(), and staticInit().
Referenced by discrLevel().
|
staticprivate |
Referenced by despike(), and incrementStatistics().