Go to the documentation of this file.
46 #ifndef GNSSTK_ROBUSTSTATS_HPP
47 #define GNSSTK_ROBUSTSTATS_HPP
60 #define ABSOLUTE(x) ((x) < T() ? -(x) : (x))
63 #define RobustTuningT (1.5) // or 1.345
66 #define RobustTuningA (0.778) // or 0.67
69 #define RobustTuningE (0.6745) // so MAD of a std normal dist is StdDev
110 template <
typename T>
116 for (i = 1; i < na; i = i + 1)
120 while ((j >= 0) && (comp(stemp, sa[j]) < 0))
138 template <
typename T>
159 }
while (comp(sa[i], spart) < 0);
163 }
while (comp(sa[j], spart) > 0);
184 QSort(&(sa[i]), nr, comp);
197 template <
typename T,
typename S>
204 for (i = 1; i < na; i = i + 1)
209 while ((j >= 0) && (comp(stemp, sa[j]) < 0))
228 template <
typename T,
typename S>
250 }
while (comp(sa[i], spart) < 0);
254 }
while (comp(sa[j], spart) > 0);
272 QSort(sa, pa, i, comp);
279 QSort(&(sa[i]), &(pa[i]), nr, comp);
296 t = T(1) / (T(1) + z / T(2));
299 ::exp(-z * z - 1.26551223 +
308 t * 0.17087277)))))))));
309 return (x >= T(0) ? ret : T(2) - ret);
327 T
arg = (x - m) / (::sqrt(T(2.0)) * s);
328 return (T(1) - errfc<T>(
arg) / T(2));
345 double ADtest(
double *xd,
const int nd,
double m,
double s,
346 bool save_flag =
true);
361 template <
typename T> T
Median(T *xd,
const int nd,
bool save_flag =
true)
379 Exception e(
"Could not allocate temporary array");
382 for (i = 0; i <
nd; i++)
390 med = xd[(
nd + 1) / 2 - 1];
394 med = (xd[
nd / 2 - 1] + xd[
nd / 2]) / T(2);
400 for (i = 0; i <
nd; i++)
424 template <
typename T>
445 Q1 = xd[(q + 1) / 2 - 1];
446 Q3 = xd[
nd - (q + 1) / 2];
450 Q1 = (xd[q / 2 - 1] + xd[q / 2]) / T(2);
451 Q3 = (xd[
nd - q / 2] + xd[
nd - q / 2 - 1]) / T(2);
466 template <
typename T>
484 Exception e(
"Could not allocate temporary array");
487 for (i = 0; i <
nd; i++)
495 for (i = 0; i <
nd; i++)
507 for (i = 0; i <
nd; i++)
520 template <
typename T> T
MAD(T *xd,
int nd, T& M,
bool save_flag =
true)
540 template <
typename T>
545 T tv, m, mold,
sum, sumw, *wt, weight;
563 for (i = 0; i <
nd; i++)
576 *wt = -tv / (xd[i] - m);
578 else if (xd[i] > m + tv)
580 *wt = tv / (xd[i] - m);
583 sum += (*wt) * xd[i];
587 }
while (T(
ABSOLUTE((m - mold) / m)) > tol && n < N);
621 int RobustPolyFit(
double *xd,
const double *td,
int nd,
int n,
double *c,
635 const std::string& msg = std::string(
""));
double ADtest(double *xd, const int nd, double m, double s, bool save_flag=true)
void Quantiles(double *xd, long nd)
T Median(T *xd, const int nd, bool save_flag=true)
T normalCDF(T m, T s, T x)
T sum(const ConstVectorBase< T, BaseClass > &l)
void Quartiles(const T *xd, const int nd, T &Q1, T &Q3)
void insert(T *sa, int na, int(*comp)(const T &, const T &)=gnsstk::Qsort_compare)
#define GNSSTK_RETHROW(exc)
#define RobustTuningT
tuning constant used in M-estimate and Robust least squares (SRIFilter.cpp)
void QSort(T *sa, int na, int(*comp)(const T &, const T &)=gnsstk::Qsort_compare)
#define GNSSTK_THROW(exc)
#define RobustTuningE
tuning constant used in MAD
int RobustPolyFit(double *xd, const double *td, int nd, int n, double *c, double *w=NULL)
T MAD(T *xd, int nd, T &M, bool save_flag=true)
T MEstimate(const T *xd, int nd, const T &M, const T &MAD, T *w=NULL)
T mad(const gnsstk::Vector< T > &v)
median absolute deviation of a gnsstk::Vector
int Qsort_compare(const T &a, const T &b)
void StemLeafPlot(std::ostream &os, double *xd, long nd, const std::string &msg=std::string(""))
T MedianAbsoluteDeviation(T *xd, int nd, T &M, bool save_flag=true)
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41