37 JParser<> zap(
"Example program to test quantile calculation.");
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
52 if (numberOfEvents < 2) {
53 FATAL(
"Fatal error: number of events " << numberOfEvents << endl);
56 gRandom->SetSeed(seed);
63 for (
int i = 0;
i != numberOfEvents; ++
i) {
65 double x = gRandom->Uniform(-1.0e6, +1.0e6);
75 for (
int i = 0;
i != 100; ++
i) {
77 std::shuffle(buffer.begin(), buffer.end(), g);
79 DEBUG(
"buffer[0] " <<
FIXED(15,6) << buffer[0] << endl);
83 for (
const double x : buffer) {
87 ASSERT( Q.getCount() == R.getCount(),
"Test shuffle counts.");
88 ASSERT(fabs(Q.getMean() - R.getMean()) <= precision,
"Test shuffle means.");
89 ASSERT(fabs(Q.getSTDev() - R.getSTDev()) <= precision,
"Test shuffle sigmas.");
95 for (
int i = 0;
i != numberOfEvents; ++
i) {
96 Q.put(gRandom->Gaus(x,
sigma));
99 NOTICE(
"quantity " <<
CENTER(10) <<
"calculated" <<
" | " <<
CENTER(10) <<
"true" << endl);
100 NOTICE(
"mean " <<
FIXED(10,3) << Q.getMean() <<
" | " <<
FIXED(10,3) << x << endl);
103 ASSERT(numberOfEvents > 0,
"Test number of events.");
104 ASSERT(fabs(Q.getMean() -
x) <= precision,
"Test mean.");
105 ASSERT(fabs(Q.getSTDev() -
sigma) <= precision,
"Test sigma.");
108 JQuantile
Q(
"",
true);
110 for (
int i = 0;
i != numberOfEvents; ++
i) {
111 Q.put(gRandom->Uniform(0.0, 1.0));
114 for (
const double x : { 0.1, 0.5, 0.9}) {
116 NOTICE(
"forward quantile " <<
FIXED(6,3) << x <<
' ' <<
FIXED(6,3) << Q.getQuantile(x, JQuantile::forward_t) << endl);
117 NOTICE(
"symmetric quantile " <<
FIXED(6,3) << x <<
' ' <<
FIXED(6,3) << Q.getQuantile(x, JQuantile::symmetric_t) << endl);
118 NOTICE(
"backward quantile " <<
FIXED(6,3) << x <<
' ' <<
FIXED(6,3) << Q.getQuantile(x, JQuantile::backward_t) << endl);
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 ");
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
Auxiliary data structure for floating point format specification.
Auxiliary data structure for alignment of data.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then JCookie sh JDataQuality D $DETECTOR_ID R
#define DEBUG(A)
Message macros.