Stats_TwoSampleStats_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #include "Stats.hpp"
40 #include "Vector.hpp"
41 #include "TestUtil.hpp"
42 #include <iostream>
43 
44 using namespace std;
45 
46 #define TUA(EXP,GOT,METHOD) testFramework.changeSourceMethod(METHOD); testFramework.assert_equals<int>(EXP,GOT,__LINE__)
47 #define TUAE(EXP,GOT,EPS,METHOD) testFramework.changeSourceMethod(METHOD); testFramework.assert_equals(T(EXP),GOT,__LINE__,"",EPS)
48 
49 template<class T>
50 size_t statsTest()
51 {
52  std::string typeName = gnsstk::typeString<T>();
53  T precision = 10*std::numeric_limits<T>::epsilon();
54  gnsstk::TestUtil testFramework( "Stats<"+typeName+">", "--", __FILE__, __LINE__ );
55 
57 
58  tso.Add(1, 2);
59  tso.Add(2, 5);
60  tso.Add(3, 1);
61  tso.Add(4, 4);
62  tso.Add(5, 3);
63  TUA(5, tso.N(), "Add()");
64 
65  TUAE(3, tso.AverageX(), precision, "AverageX()");
66  TUAE(5, tso.MaximumX(), precision, "MaxX()");
67  TUAE(1, tso.MinimumX(), precision, "MinX()");
68  TUAE(2.5, tso.VarianceX(), precision, "VarianceX()");
69  TUAE(sqrt(2.5), tso.StdDevX(), precision, "StdDevX()");
70 
71  TUAE(3, tso.AverageY(), precision, "AverageY()");
72  TUAE(5, tso.MaximumY(), precision, "MaxY()");
73  TUAE(1, tso.MinimumY(), precision, "MinY()");
74  TUAE(2.5, tso.VarianceY(), precision, "VarianceY()");
75  TUAE(sqrt(2.5), tso.StdDevY(), precision, "StdDevY()");
76 
77  TUAE(0.1, tso.Slope(), precision, "Slope()");
78  TUAE(2.7, tso.Intercept(), precision, "Intercept()");
79  TUAE(0.574456264653802865989, tso.SigmaSlope(), precision, "SigmaSlope()");
80  TUAE(1.81659021245849499920, tso.SigmaYX(), precision, "SigmaYX()");
81  TUAE(0.1, tso.Correlation(), precision, "Correlation()");
82 
83  return testFramework.countFails();
84 }
85 
86 
87 int main()
88 {
89  unsigned ec=0;
90  ec += statsTest<float>();
91  ec += statsTest<double>();
92  ec += statsTest<long double>();
93 
94  cout << "Total Failures for " << __FILE__ << ": " << ec << endl;
95  return ec;
96 }
gnsstk::TestUtil::countFails
int countFails(void)
Definition: TestUtil.hpp:771
gnsstk::TwoSampleStats::Add
void Add(const T &x, const T &y)
Definition: Stats.hpp:867
gnsstk::TwoSampleStats::Slope
T Slope(void) const
return slope of best-fit line Y=slope*X + intercept
Definition: Stats.hpp:1060
gnsstk::TwoSampleStats::StdDevY
T StdDevY(void) const
return computed Y standard deviation
Definition: Stats.hpp:1057
gnsstk::TwoSampleStats::Intercept
T Intercept(void) const
return intercept of best-fit line Y=slope*X + intercept
Definition: Stats.hpp:1072
gnsstk::TwoSampleStats::MinimumX
T MinimumX(void) const
return minimum X value
Definition: Stats.hpp:1039
gnsstk::TwoSampleStats::SigmaYX
T SigmaYX(void) const
return conditional uncertainty = uncertainty y given x
Definition: Stats.hpp:1105
TUA
#define TUA(EXP, GOT, METHOD)
Definition: Stats_TwoSampleStats_T.cpp:46
Stats.hpp
gnsstk::TwoSampleStats::AverageY
T AverageY(void) const
return computed Y average
Definition: Stats.hpp:1049
TestUtil.hpp
gnsstk::TwoSampleStats::MaximumX
T MaximumX(void) const
return maximum X value
Definition: Stats.hpp:1041
gnsstk::TwoSampleStats::MaximumY
T MaximumY(void) const
return maximum Y value
Definition: Stats.hpp:1045
gnsstk::TwoSampleStats::SigmaSlope
T SigmaSlope(void) const
return uncertainty in slope
Definition: Stats.hpp:1081
gnsstk::TwoSampleStats::AverageX
T AverageX(void) const
return computed X average
Definition: Stats.hpp:1047
gnsstk::TwoSampleStats::VarianceX
T VarianceX(void) const
return computed X variance
Definition: Stats.hpp:1051
gnsstk::TwoSampleStats::Correlation
T Correlation(void) const
return correlation
Definition: Stats.hpp:1093
TUAE
#define TUAE(EXP, GOT, EPS, METHOD)
Definition: Stats_TwoSampleStats_T.cpp:47
gnsstk::TwoSampleStats::StdDevX
T StdDevX(void) const
return computed X standard deviation
Definition: Stats.hpp:1055
std
Definition: Angle.hpp:142
gnsstk::TwoSampleStats::VarianceY
T VarianceY(void) const
return computed Y variance
Definition: Stats.hpp:1053
gnsstk::TwoSampleStats::MinimumY
T MinimumY(void) const
return minimum Y value
Definition: Stats.hpp:1043
gnsstk::TwoSampleStats::N
unsigned int N(void) const
Definition: Stats.hpp:1037
gnsstk::TwoSampleStats
Definition: Stats.hpp:126
main
int main()
Definition: Stats_TwoSampleStats_T.cpp:87
gnsstk::TestUtil
Definition: TestUtil.hpp:265
Vector.hpp
statsTest
size_t statsTest()
Definition: Stats_TwoSampleStats_T.cpp:50


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