Robust statistics.
Functions | |
template<typename T > | |
T | MAD (T *xd, int nd, T &M, bool save_flag=true) |
template<typename T > | |
T | Median (T *xd, const int nd, bool save_flag=true) |
template<typename T > | |
T | MedianAbsoluteDeviation (T *xd, int nd, T &M, bool save_flag=true) |
template<typename T > | |
T | MEstimate (const T *xd, int nd, const T &M, const T &MAD, T *w=NULL) |
void | Quantiles (double *xd, long nd) |
template<typename T > | |
void | Quartiles (const T *xd, const int nd, T &Q1, T &Q3) |
int | RobustPolyFit (double *xd, const double *td, int nd, int n, double *c, double *w=NULL) |
void | StemLeafPlot (std::ostream &os, double *xd, long nd, const std::string &msg=std::string("")) |
T gnsstk::Robust::MAD | ( | T * | xd, |
int | nd, | ||
T & | M, | ||
bool | save_flag = true |
||
) |
Compute the median absolute deviation of a double array of length nd; see MedianAbsoluteDeviation().
Exception |
Definition at line 520 of file RobustStats.hpp.
T gnsstk::Robust::Median | ( | T * | xd, |
const int | nd, | ||
bool | save_flag = true |
||
) |
Compute median of an array of length nd; array xd is returned sorted, unless save_flag is true.
xd | array of data. |
nd | length of array xd. |
save_flag | if true (default) array xd will NOT be changed, otherwise it will be sorted. |
Exception |
Definition at line 361 of file RobustStats.hpp.
T gnsstk::Robust::MedianAbsoluteDeviation | ( | T * | xd, |
int | nd, | ||
T & | M, | ||
bool | save_flag = true |
||
) |
Compute the median absolute deviation of a double array of length nd, as well as the median (M = Median(xd,nd));
xd | array of data (input). |
nd | length of array xd (input). |
M | median of data in array xd (output). |
save_flag | if true (default), array xd will NOT be trashed. |
Exception |
Definition at line 467 of file RobustStats.hpp.
T gnsstk::Robust::MEstimate | ( | const T * | xd, |
int | nd, | ||
const T & | M, | ||
const T & | MAD, | ||
T * | w = NULL |
||
) |
Compute the m-estimate. Iteratively determine the m-estimate, which is a measure of mean or median, but is less sensitive to outliers. M is the median (M=Median(xd,nd)), and MAD is the median absolute deviation (MAD=MedianAbsoluteDeviation(xd,nd,M)). Optionally, a pointer to an array, which will contain the weights on output, may be provided.
xd | input array of data. |
nd | input length of array xd. |
M | input median of data in array xd. |
MAD | input median absolute deviation of data in array xd. |
w | output array of length nd to contain weights on output. |
Exception |
Definition at line 541 of file RobustStats.hpp.
void gnsstk::Robust::Quantiles | ( | double * | xd, |
long | nd | ||
) |
Generate quantiles. Given an array xd of length nd, fill it with quantiles such that (xd,yd) gives a quantile plot. The distribution of yd is a normal distribution to the extent that this plot is a straight line, with y-intercept and slope identified with mean and standard deviation, respectively, of the distribution.
xd | array of length nd containing quantiles on output. |
nd | length of array xd. |
Exception |
Definition at line 350 of file RobustStats.cpp.
Compute the quartiles Q1 and Q3 of an array of length nd. Array is assumed sorted in ascending order. Quartile are values such that one fourth of the samples are larger (smaller) than Q3(Q1).
xd | array of data. |
nd | length of array xd. |
Q1 | (output) first quartile of data in array xd. |
Q3 | (output) third quartile of data in array xd. |
Exception |
Definition at line 425 of file RobustStats.hpp.
int gnsstk::Robust::RobustPolyFit | ( | double * | xd, |
const double * | td, | ||
int | nd, | ||
int | n, | ||
double * | c, | ||
double * | w = NULL |
||
) |
Fit a polynomial of degree n to data xd, with independent variable td, using robust techniques. The post-fit residuals are returned in the data vector, and the computed weights in the result may be output as well. Specifically, the equation describing the fit is c0 + c[1]*t(j) + c[2]*t(j)*t(j) + ... c[n-1]*pow(t(j),n-1) = xd[j], where the zero-th coefficient and the independent variable are debiased by the first value; i.e. c0 = c[0]+xd[0] and t(j) = td[i]-td[0]. Specifically, to evaluate the polynomial at t, eval = f(t), do the following. xd0 = xd[0]; Robust::RobustPolyFit(xd,td,nd,n,c); eval = xd0+c[0]; tt = 1.0; for(j=1; j<nd; j++) { tt *= (t-td[0]); eval += c[j]*tt; }
[in] | xd | array of data, of length nd; contains residuals on output. |
[in] | td | array of independent variable, length nd (parallel to xd). |
[in] | nd | length of arrays xd and td. |
[in] | n | degree of polynomial and dimension of coefficient array. |
[out] | c | array of coefficients (dimension n). |
[out] | w | array of length nd to contain weights. |
Exception |
Definition at line 368 of file RobustStats.cpp.
void gnsstk::Robust::StemLeafPlot | ( | std::ostream & | os, |
double * | xd, | ||
long | nd, | ||
const std::string & | msg = std::string("") |
||
) |
Print 'stem and leaf' plot of the data in the double array xd of length nd, with an optional message, on the given output ostream. It is assumed that the input array xd is sorted in ascending order.
os | ostream on which to write output. |
xd | array of data. |
nd | length of array xd. |
msg | string containing optional message for output. |
Exception |
Definition at line 70 of file RobustStats.cpp.