{ "cells": [ { "cell_type": "markdown", "id": "21874269", "metadata": {}, "source": [ "# qa2\n", "Test generation of random numbers distributed according to a function defined by the user.\n", "\n", "\n", "\n", "\n", "**Author:** Rene Brun \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Sunday, December 21, 2025 at 02:49 PM." ] }, { "cell_type": "markdown", "id": "adb28949", "metadata": {}, "source": [ "Fill a 1-D histogram from a parametric function" ] }, { "cell_type": "code", "execution_count": 1, "id": "a0aac945", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2025-12-21T13:49:27.445485Z", "iopub.status.busy": "2025-12-21T13:49:27.445361Z", "iopub.status.idle": "2025-12-21T13:49:27.858436Z", "shell.execute_reply": "2025-12-21T13:49:27.842504Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\",\"The FillRandom example\",0,0,700,500);\n", "\n", "gBenchmark->Start(\"fillrandom\");" ] }, { "cell_type": "markdown", "id": "7bec3935", "metadata": {}, "source": [ "A function (any dimension) or a formula may reference\n", "an already defined formula" ] }, { "cell_type": "code", "execution_count": 2, "id": "d0dc0c18", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2025-12-21T13:49:27.879842Z", "iopub.status.busy": "2025-12-21T13:49:27.879635Z", "iopub.status.idle": "2025-12-21T13:49:28.092958Z", "shell.execute_reply": "2025-12-21T13:49:28.092399Z" } }, "outputs": [], "source": [ "TFormula *form1 = new TFormula(\"form1\",\"abs(sin(x)/x)\");\n", "TF1 *sqroot = new TF1(\"sqroot\",\"x*gaus(0) + [3]*form1\",0,10);\n", "sqroot->SetParameters(10,4,1,20);" ] }, { "cell_type": "markdown", "id": "7a820221", "metadata": {}, "source": [ "Create a one dimensional histogram (one float per bin)\n", "and fill it following the distribution in function sqroot." ] }, { "cell_type": "code", "execution_count": 3, "id": "206ea1b4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2025-12-21T13:49:28.097773Z", "iopub.status.busy": "2025-12-21T13:49:28.097633Z", "iopub.status.idle": "2025-12-21T13:49:28.305133Z", "shell.execute_reply": "2025-12-21T13:49:28.304594Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "