{ "cells": [ { "cell_type": "markdown", "id": "969b5240", "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 Tuesday, May 19, 2026 at 08:27 PM." ] }, { "cell_type": "markdown", "id": "2c8f8913", "metadata": {}, "source": [ "Fill a 1-D histogram from a parametric function" ] }, { "cell_type": "code", "execution_count": 1, "id": "dafa0e15", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:27:14.807555Z", "iopub.status.busy": "2026-05-19T20:27:14.807444Z", "iopub.status.idle": "2026-05-19T20:27:15.157334Z", "shell.execute_reply": "2026-05-19T20:27:15.156750Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\",\"The FillRandom example\",0,0,700,500);\n", "\n", "gBenchmark->Start(\"fillrandom\");" ] }, { "cell_type": "markdown", "id": "1f3b578e", "metadata": {}, "source": [ "A function (any dimension) or a formula may reference\n", "an already defined formula" ] }, { "cell_type": "code", "execution_count": 2, "id": "53d8ee78", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:27:15.159325Z", "iopub.status.busy": "2026-05-19T20:27:15.159202Z", "iopub.status.idle": "2026-05-19T20:27:15.366206Z", "shell.execute_reply": "2026-05-19T20:27:15.365666Z" } }, "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": "baec7f4d", "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": "68466a00", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:27:15.368080Z", "iopub.status.busy": "2026-05-19T20:27:15.367965Z", "iopub.status.idle": "2026-05-19T20:27:15.574810Z", "shell.execute_reply": "2026-05-19T20:27:15.574275Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "