Functions
gnsstk::Robust Namespace Reference

Detailed Description

Robust statistics.

Functions

template<typename T >
MAD (T *xd, int nd, T &M, bool save_flag=true)
 
template<typename T >
Median (T *xd, const int nd, bool save_flag=true)
 
template<typename T >
MedianAbsoluteDeviation (T *xd, int nd, T &M, bool save_flag=true)
 
template<typename 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(""))
 

Function Documentation

◆ MAD()

template<typename T >
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().

Exceptions
Exception

Definition at line 520 of file RobustStats.hpp.

◆ Median()

template<typename T >
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.

Parameters
xdarray of data.
ndlength of array xd.
save_flagif true (default) array xd will NOT be changed, otherwise it will be sorted.
Returns
median of the data in array xd.
Exceptions
Exception

Definition at line 361 of file RobustStats.hpp.

◆ MedianAbsoluteDeviation()

template<typename T >
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));

Note
this routine will trash the array xd unless save_flag is true (default).
Parameters
xdarray of data (input).
ndlength of array xd (input).
Mmedian of data in array xd (output).
save_flagif true (default), array xd will NOT be trashed.
Returns
median absolute deviation of data in array xd.
Exceptions
Exception

Definition at line 467 of file RobustStats.hpp.

◆ MEstimate()

template<typename T >
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.

Parameters
xdinput array of data.
ndinput length of array xd.
Minput median of data in array xd.
MADinput median absolute deviation of data in array xd.
woutput array of length nd to contain weights on output.
Returns
m-estimate of data in array xd.
Exceptions
Exception

Definition at line 541 of file RobustStats.hpp.

◆ Quantiles()

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.

Parameters
xdarray of length nd containing quantiles on output.
ndlength of array xd.
Exceptions
Exception

Definition at line 350 of file RobustStats.cpp.

◆ Quartiles()

template<typename T >
void gnsstk::Robust::Quartiles ( const T *  xd,
const int  nd,
T &  Q1,
T &  Q3 
)

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).

Parameters
xdarray of data.
ndlength of array xd.
Q1(output) first quartile of data in array xd.
Q3(output) third quartile of data in array xd.
Exceptions
Exception

Definition at line 425 of file RobustStats.hpp.

◆ RobustPolyFit()

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; }

Parameters
[in]xdarray of data, of length nd; contains residuals on output.
[in]tdarray of independent variable, length nd (parallel to xd).
[in]ndlength of arrays xd and td.
[in]ndegree of polynomial and dimension of coefficient array.
[out]carray of coefficients (dimension n).
[out]warray of length nd to contain weights.
Returns
0 for success, -1 for singular problem, -2 failure to converge.
Exceptions
Exception

Definition at line 368 of file RobustStats.cpp.

◆ StemLeafPlot()

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.

Parameters
osostream on which to write output.
xdarray of data.
ndlength of array xd.
msgstring containing optional message for output.
Exceptions
Exception

Definition at line 70 of file RobustStats.cpp.



gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:46