33#include "DGtal/math/Statistic.h"
49 unsigned int nbok = 0;
52 trace.beginBlock (
"Testing Statistics ..." );
56 for(
unsigned int k=0; k < 1000; k++)
61 trace.info() <<
"Mean value = "<<stat.
mean() << std::endl;
62 nbok += (stat.
mean()==499.5) ? 1 : 0;
63 trace.info() <<
"Variance value = "<<stat.
variance()<<std::endl;
64 trace.info() <<
"Max value = "<<stat.
max()<<std::endl;
65 nbok += (stat.
max()==999) ? 1 : 0;
66 trace.info() <<
"Min value = "<<stat.
min()<<std::endl;
67 nbok += (stat.
min()==0) ? 1 : 0;
69 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
70 <<
"true == true" << std::endl;
82 unsigned int nbok = 0;
85 trace.beginBlock (
"Testing Statistics with saving option ..." );
90 for(
unsigned int k=0; k < 100; k++)
93 for(
unsigned int k=0; k < 100; k++)
98 trace.info() <<
"Mean value = "<<stat.
mean() << std::endl;
99 nbok += (stat.
mean()==88) ? 1 : 0;
100 trace.info() <<
"Variance value = "<<stat.
variance()<<std::endl;
101 trace.info() <<
"Max value = "<<stat.
max()<<std::endl;
102 nbok += (stat.
max()==99) ? 1 : 0;
103 trace.info() <<
"Min value = "<<stat.
min()<<std::endl;
104 nbok += (stat.
min()==77) ? 1 : 0;
105 trace.info() <<
"Median value = "<<stat.
median()<<std::endl;
106 nbok += (stat.
median()==88) ? 1 : 0;
108 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
109 <<
"true == true" << std::endl;
118int main(
int argc,
char** argv )
120 trace.beginBlock (
"Testing class Statistics" );
121 trace.info() <<
"Args:";
122 for (
int i = 0; i < argc; ++i )
123 trace.info() <<
" " << argv[ i ];
124 trace.info() << endl;
127 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
129 trace.beginBlock (
"Testing class Statistics (with option for saving samples)" );
130 trace.info() <<
"Args:";
131 for (
int i = 0; i < argc; ++i )
132 trace.info() <<
" " << argv[ i ];
133 trace.info() << endl;
136 trace.emphase() << ( res2 ?
"Passed." :
"Error." ) << endl;
140 return (res &&res2) ? 0 : 1;
118int main(
int argc,
char** argv ) {
…}
Aim: This class processes a set of sample values for one variable and can then compute different stat...
void addValue(Quantity v)
DGtal is the top-level namespace which contains all DGtal functions and types.
bool testStatisticsSaving()