{
"cells": [
{
"cell_type": "markdown",
"id": "1f35f503",
"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 Wednesday, December 17, 2025 at 02:53 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4f1ae360",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:57.858734Z",
"iopub.status.busy": "2025-12-17T13:53:57.858522Z",
"iopub.status.idle": "2025-12-17T13:53:58.398125Z",
"shell.execute_reply": "2025-12-17T13:53:58.387651Z"
}
},
"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": "35feab8f",
"metadata": {},
"source": [
"show the original histogram in the top pad"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "50f4af13",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:58.409742Z",
"iopub.status.busy": "2025-12-17T13:53:58.409497Z",
"iopub.status.idle": "2025-12-17T13:53:58.616857Z",
"shell.execute_reply": "2025-12-17T13:53:58.616287Z"
}
},
"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": "56941259",
"metadata": {},
"source": [
"show the final quantiles in the middle pad"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4d864026",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:58.624000Z",
"iopub.status.busy": "2025-12-17T13:53:58.623808Z",
"iopub.status.idle": "2025-12-17T13:53:58.829794Z",
"shell.execute_reply": "2025-12-17T13:53:58.829206Z"
}
},
"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": "24143a09",
"metadata": {},
"source": [
"show the evolution of some quantiles in the bottom pad"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "50cf237d",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:58.841830Z",
"iopub.status.busy": "2025-12-17T13:53:58.841574Z",
"iopub.status.idle": "2025-12-17T13:53:59.068788Z",
"shell.execute_reply": "2025-12-17T13:53:59.064370Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\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": "466491ab",
"metadata": {},
"source": [
"add a legend"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "206b9d57",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:59.077898Z",
"iopub.status.busy": "2025-12-17T13:53:59.077607Z",
"iopub.status.idle": "2025-12-17T13:53:59.286671Z",
"shell.execute_reply": "2025-12-17T13:53:59.285976Z"
}
},
"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": "ed2ef541",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6385ace6",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2025-12-17T13:53:59.289061Z",
"iopub.status.busy": "2025-12-17T13:53:59.288880Z",
"iopub.status.idle": "2025-12-17T13:53:59.502575Z",
"shell.execute_reply": "2025-12-17T13:53:59.501797Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\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
}