Example program to test JTOOLS::JQuantile calculation.
More...
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TRandom.h"
#include "JTools/JQuantile.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to test JTOOLS::JQuantile calculation.
- Author
- mdejong
Definition in file JQuantile.cc.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 21 of file JQuantile.cc.
35 JParser<> zap(
"Example program to test quantile calculation.");
46 catch(
const exception &error) {
47 FATAL(error.what() << endl);
50 if (numberOfEvents < 2) {
51 FATAL(
"Fatal error: number of events " << numberOfEvents << endl);
54 gRandom->SetSeed(seed);
59 for (
int i = 0; i != numberOfEvents; ++i) {
60 Q.put(gRandom->Gaus(
x,
sigma));
63 NOTICE(
"quantity " <<
CENTER(10) <<
"calculated" <<
" | " <<
CENTER(10) <<
"true" << endl);
64 NOTICE(
"mean " <<
FIXED(10,3) << Q.getMean() <<
" | " <<
FIXED(10,3) <<
x << endl);
67 ASSERT(numberOfEvents > 0,
"Test number of events.");
68 ASSERT(fabs(Q.getMean() -
x) <= precision,
"Test mean.");
69 ASSERT(fabs(Q.getSTDev() -
sigma) <= precision,
"Test sigma.");
72 JQuantile
Q(
"",
true);
74 for (
int i = 0; i != numberOfEvents; ++i) {
75 Q.put(gRandom->Uniform(0.0, 1.0));
78 for (
const double x : { 0.1, 0.5, 0.9}) {
80 NOTICE(
"forward quantile " <<
FIXED(6,3) <<
x <<
' ' <<
FIXED(6,3) << Q.getQuantile(
x, JQuantile::forward_t) << endl);
81 NOTICE(
"symmetric quantile " <<
FIXED(6,3) <<
x <<
' ' <<
FIXED(6,3) << Q.getQuantile(
x, JQuantile::symmetric_t) << endl);
82 NOTICE(
"backward quantile " <<
FIXED(6,3) <<
x <<
' ' <<
FIXED(6,3) << Q.getQuantile(
x, JQuantile::backward_t) << endl);
84 ASSERT(fabs(Q.getQuantile(
x, JQuantile::forward_t) - (
x )) <= precision,
"Test forward quantile ");
85 ASSERT(fabs(Q.getQuantile(
x, JQuantile::symmetric_t) - (
x )) <= precision,
"Test symmetric quantile ");
86 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