24{
   27 
   28  int       numberOfEvents;
   31  ULong_t   seed;
   32  double    precision;
   34 
   35  try {
   36 
   37    JParser<> zap(
"Example program to test quantile calculation.");
 
   38 
   45 
   46    zap(argc, argv);
   47  }
   48  catch(const exception &error) {
   49    FATAL(error.what() << endl);
 
   50  }
   51 
   52  if (numberOfEvents < 2) {
   53    FATAL(
"Fatal error: number of events " << numberOfEvents << endl);
 
   54  }
   55 
   56  gRandom->SetSeed(seed);
   57 
   58  {
   60    
   62 
   63    for (int i = 0; i != numberOfEvents; ++i) {
   64 
   65      double x = gRandom->Uniform(-1.0e6, +1.0e6);
 
   66 
   67      buffer.push_back(x);
   68 
   70    }
   71 
   72    random_device rd;
   73    mt19937 g(rd());
   74 
   75    for (int i = 0; i != 100; ++i) {
   76 
   77      std::shuffle(buffer.begin(), buffer.end(), g);
   78 
   79      DEBUG(
"buffer[0] " << 
FIXED(15,6) << buffer[0] << endl);
 
   80 
   82 
   83      for (const double x : buffer) {
   85      }
   86 
   90    }
   91  }
   92  {
   94 
   95    for (int i = 0; i != numberOfEvents; ++i) {
   96      Q.
put(gRandom->Gaus(x, sigma));
 
   97    }
   98 
   99    NOTICE(
"quantity  " << 
CENTER(10)  << 
"calculated" << 
" | " << 
CENTER(10)  << 
"true" << endl);
 
  102 
  103    ASSERT(numberOfEvents             >  0,         
"Test number of events.");
 
  106  }
  107  {
  109 
  110    for (int i = 0; i != numberOfEvents; ++i) {
  111      Q.
put(gRandom->Uniform(0.0, 1.0));
 
  112    }
  113 
  114    for (const double x : { 0.1, 0.5, 0.9}) {
  115 
  119 
  120      ASSERT(fabs(Q.
getQuantile(x, JQuantile::forward_t)   - (   x   )) <= precision, 
"Test forward quantile ");
 
  121      ASSERT(fabs(Q.
getQuantile(x, JQuantile::symmetric_t) - (   x   )) <= precision, 
"Test symmetric quantile ");
 
  122      ASSERT(fabs(Q.
getQuantile(x, JQuantile::backward_t)  - (1.0 - x)) <= precision, 
"Test backward quantile ");
 
  123    }
  124  }
  125  
  126  return 0;
  127}
#define DEBUG(A)
Message macros.
 
#define ASSERT(A,...)
Assert macro.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Utility class to parse command line options.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary data structure for alignment of data.
 
Auxiliary data structure for floating point format specification.