13.2.14. Macro “dataserverComputeQuantileVec.C”
13.2.14.1. Objective
This part shows the complete code used to produce the console display in computeQuantile.
13.2.14.2. Macro Uranie
TDataServer *tdsvec = new TDataServer("foo", "bar");
tdsvec->fileDataRead("aTDSWithVectors.dat");
double probas[3]={0.2, 0.6, 0.8}; double quants[3];
tdsvec->computeQuantile("rank", 3, probas, quants);
TAttribute *prank = tdsvec->getAttribute("rank");
int nbquant;
prank->getQuantilesSize(nbquant); // (1)
cout << "nbquant = " << nbquant << endl;
double aproba=0.8; double aquant;
prank->getQuantile(aproba, aquant); // (2)
cout << "aproba = " << aproba << ", aquant = " <<
aquant << endl;
double theproba[3], thequant[3];
prank->getQuantiles(theproba, thequant); // (3)
for(int i_quant=0; i_quant<nbquant; ++i_quant) {
cout << "(theproba, thequant)[" << i_quant << "] = "
<< "(" << theproba[i_quant] << ", " <<
thequant[i_quant] << ")" << endl;
}
vector<double> allquant;
prank->getQuantileVector(aproba, allquant); // (4)
cout << "aproba = " << aproba << ", allquant = ";
for(double quant_i: allquant)
cout << quant_i << " ";
cout << endl;
13.2.14.3. Console
This macro should result in this output in console:
nbquant = 3
aproba = 0.8, aquant = 6.4
(theproba, thequant)[0] = (0.2, 1.6)
(theproba, thequant)[1] = (0.6, 4.8)
(theproba, thequant)[2] = (0.8, 6.4)
aproba = 0.8, allquant = 6.4 7.4