DGtal  1.5.beta
testMultiStatistics.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/math/MultiStatistics.h"
Include dependency graph for testMultiStatistics.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Testing MultiStatistics")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2015/11/10

Functions for testing class MultiStatistics.

This file is part of the DGtal library.

Definition in file testMultiStatistics.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing MultiStatistics )

Definition at line 46 of file testMultiStatistics.cpp.

47 {
48  MultiStatistics stats (100, false);
49  for(unsigned int i = 0; i< 100; i++)
50  {
51  for(unsigned int j = 0; j<= i; j++)
52  {
53  stats.addValue(i, j);
54  }
55  }
56  stats.terminate();
57 
58  SECTION("Testing multiStatics estimated quantities without saving the data")
59  {
60  unsigned int val = 50;
61  REQUIRE( stats.max(val) == val );
62  REQUIRE( stats.min(val) == 0 );
63  REQUIRE( stats.mean(val) == val/2.0 );
64  val = 31;
65  REQUIRE( stats.max(val) == val );
66  REQUIRE( stats.min(val) == 0 );
67  REQUIRE( stats.mean(val) == val/2.0 );
68  }
69 
70  MultiStatistics stats2 (100, true);
71  for(unsigned int i = 0; i< 100; i++)
72  {
73  for(unsigned int j = 0; j<= i; j++)
74  {
75  stats2.addValue(i, j);
76  }
77  }
78  stats2.terminate();
79 
80  SECTION("Testing multiStatics estimated quantities with saving the data")
81  {
82  unsigned int val = 12;
83  REQUIRE( stats2.max(val) == val );
84  REQUIRE( stats2.min(val) == 0 );
85  REQUIRE( stats2.mean(val) == val/2.0 );
86  REQUIRE( stats2.median(val) == ((val+1)/2) );
87  val = 33;
88  REQUIRE( stats2.max(val) == val );
89  REQUIRE( stats2.min(val) == 0 );
90  REQUIRE( stats2.mean(val) == val/2.0 );
91  REQUIRE( stats2.median(val) == ((val+1)/2) );
92  }
93 
94 
95  MultiStatistics stats3 (100, true);
96  for(unsigned int i = 0; i< 100; i++)
97  {
98  std::vector<double> vectValues;
99  for(unsigned int j = 0; j<= i; j++)
100  {
101  vectValues.push_back(j);
102  }
103  stats3.addValues(i, vectValues.begin(), vectValues.end());
104  }
105  stats3.terminate();
106 
107  SECTION("Testing feature math of MultiStatistics with saving data")
108  {
109  unsigned int val = 12;
110  REQUIRE( stats3.max(val) == val );
111  REQUIRE( stats3.min(val) == 0 );
112  REQUIRE( stats3.mean(val) == val/2.0 );
113  REQUIRE( stats3.median(val) == ((val+1)/2) );
114  val = 33;
115  REQUIRE( stats3.max(val) == val );
116  REQUIRE( stats3.min(val) == 0 );
117  REQUIRE( stats3.mean(val) == val/2.0 );
118  REQUIRE( stats3.median(val) == ((val+1)/2) );
119  }
120 
121 
122 }
Aim: This class stores a set of sample values for several variables and can then compute different st...
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References DGtal::MultiStatistics::addValue(), DGtal::MultiStatistics::addValues(), DGtal::MultiStatistics::max(), DGtal::MultiStatistics::mean(), DGtal::MultiStatistics::median(), DGtal::MultiStatistics::min(), REQUIRE(), SECTION(), and DGtal::MultiStatistics::terminate().