Go to the documentation of this file.
53 using namespace Robust;
56 int main(
int argc,
char* argv[])
61 double badMeasurement = 10000;
72 for (
size_t i = 0; i<N; i++)
78 simpleStats.
Add(s[i]);
83 cout << endl <<
"Before perturbation: sample mean is "
84 << simpleStats.
Average() <<
", " << endl;
85 cout <<
" sample standard deviation is "
86 << simpleStats.
StdDev() << endl << endl;
90 size_t i = (rand()%N);
91 s[i] = badMeasurement;
92 cout <<
"Altering measurement " << i <<
" to take the value of "
93 << badMeasurement << endl;
97 for (
size_t i = 0; i<N; i++)
99 secondStats.
Add(s[i]);
104 cout << endl <<
"After perturbation: sample mean is "
105 << secondStats.
Average() <<
", " << endl;
106 cout <<
" sample standard deviation is "
107 << secondStats.
StdDev() << endl << endl;
115 cout <<
"Robust statistics:\n";
116 cout <<
" number = " << N << endl;
117 cout <<
" quartiles = " << setw(11)
118 << setprecision(8) << Q1
119 <<
" " << setw(11) << setprecision(8) << Q3 << endl;
120 cout <<
" median = " << setw(11)
121 << setprecision(8) <<
median << endl;
122 cout <<
" MAD = " << setw(11)
123 << setprecision(8) <<
mad << endl;
128 for (
size_t i = 0; i<N; i++)
131 thirdStats.
Add(s[i]);
136 cout << endl <<
"Using robust stats: sample mean is "
137 << thirdStats.
Average() <<
", " << endl;
138 cout <<
" sample standard deviation is "
139 << thirdStats.
StdDev() << endl << endl;
144 cerr <<
"Allocation error. Out of memory?" << endl;
T StdDev(void) const
return computed standard deviation
void Quartiles(const T *xd, const int nd, T &Q1, T &Q3)
int main(int argc, char *argv[])
void QSort(T *sa, int na, int(*comp)(const T &, const T &)=gnsstk::Qsort_compare)
double RandNorm(double sigma)
T Average(void) const
return the average
T median(const Vector< T > &v)
Compute the median of a gnsstk::Vector.
T mad(const gnsstk::Vector< T > &v)
median absolute deviation of a gnsstk::Vector
T MedianAbsoluteDeviation(T *xd, int nd, T &M, bool save_flag=true)
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41