{
"cells": [
{
"cell_type": "markdown",
"id": "7a9d2a4f",
"metadata": {},
"source": [
"# quantiles\n",
"Demo for quantiles.\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Rene Brun, Eddy Offermann \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:27 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8ce28043",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:20.379261Z",
"iopub.status.busy": "2026-05-19T20:27:20.379160Z",
"iopub.status.idle": "2026-05-19T20:27:20.854838Z",
"shell.execute_reply": "2026-05-19T20:27:20.854175Z"
}
},
"outputs": [],
"source": [
"const Int_t nq = 100;\n",
"const Int_t nshots = 10;\n",
"Double_t xq[nq]; // position where to compute the quantiles in [0,1]\n",
"Double_t yq[nq]; // array to contain the quantiles\n",
"for (Int_t i=0;iFillRandom(\"gaus\",50);\n",
" h->GetQuantiles(nq,yq,xq);\n",
" gr70->SetPoint(shot,shot+1,yq[70]);\n",
" gr90->SetPoint(shot,shot+1,yq[90]);\n",
" gr98->SetPoint(shot,shot+1,yq[98]);\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "66d37b2c",
"metadata": {},
"source": [
"show the original histogram in the top pad"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c2d79da7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:20.856943Z",
"iopub.status.busy": "2026-05-19T20:27:20.856823Z",
"iopub.status.idle": "2026-05-19T20:27:21.063827Z",
"shell.execute_reply": "2026-05-19T20:27:21.063177Z"
}
},
"outputs": [],
"source": [
"TCanvas *c1 = new TCanvas(\"c1\",\"demo quantiles\",10,10,600,900);\n",
"c1->Divide(1,3);\n",
"c1->cd(1);\n",
"h->SetFillColor(38);\n",
"h->Draw();"
]
},
{
"cell_type": "markdown",
"id": "97674a5e",
"metadata": {},
"source": [
"show the final quantiles in the middle pad"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b85afceb",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:21.065924Z",
"iopub.status.busy": "2026-05-19T20:27:21.065812Z",
"iopub.status.idle": "2026-05-19T20:27:21.270212Z",
"shell.execute_reply": "2026-05-19T20:27:21.269807Z"
}
},
"outputs": [],
"source": [
"c1->cd(2);\n",
"gPad->SetGrid();\n",
"TGraph *gr = new TGraph(nq,xq,yq);\n",
"gr->SetTitle(\"final quantiles\");\n",
"gr->SetMarkerStyle(21);\n",
"gr->SetMarkerColor(kRed);\n",
"gr->SetMarkerSize(0.3);\n",
"gr->Draw(\"ap\");"
]
},
{
"cell_type": "markdown",
"id": "0064c206",
"metadata": {},
"source": [
"show the evolution of some quantiles in the bottom pad"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7d7cbfc2",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:21.272472Z",
"iopub.status.busy": "2026-05-19T20:27:21.272358Z",
"iopub.status.idle": "2026-05-19T20:27:21.476982Z",
"shell.execute_reply": "2026-05-19T20:27:21.476354Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"c1->cd(3);\n",
"gPad->DrawFrame(0,0,nshots+1,3.2);\n",
"gPad->SetGrid();\n",
"gr98->SetMarkerStyle(22);\n",
"gr98->SetMarkerColor(kRed);\n",
"gr98->Draw(\"lp\");\n",
"gr90->SetMarkerStyle(21);\n",
"gr90->SetMarkerColor(kBlue);\n",
"gr90->Draw(\"lp\");\n",
"gr70->SetMarkerStyle(20);\n",
"gr70->SetMarkerColor(kMagenta);\n",
"gr70->Draw(\"lp\");"
]
},
{
"cell_type": "markdown",
"id": "ee135c3e",
"metadata": {},
"source": [
"add a legend"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2228bcf6",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:21.478840Z",
"iopub.status.busy": "2026-05-19T20:27:21.478722Z",
"iopub.status.idle": "2026-05-19T20:27:21.685765Z",
"shell.execute_reply": "2026-05-19T20:27:21.685100Z"
}
},
"outputs": [],
"source": [
"TLegend *legend = new TLegend(0.85,0.74,0.95,0.95);\n",
"legend->SetTextFont(72);\n",
"legend->SetTextSize(0.05);\n",
"legend->AddEntry(gr98,\" q98\",\"lp\");\n",
"legend->AddEntry(gr90,\" q90\",\"lp\");\n",
"legend->AddEntry(gr70,\" q70\",\"lp\");\n",
"legend->Draw();"
]
},
{
"cell_type": "markdown",
"id": "7d8bbab4",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "45f01cb1",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:21.687862Z",
"iopub.status.busy": "2026-05-19T20:27:21.687744Z",
"iopub.status.idle": "2026-05-19T20:27:21.899540Z",
"shell.execute_reply": "2026-05-19T20:27:21.898850Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%jsroot on\n",
"gROOT->GetListOfCanvases()->Draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}