{ "cells": [ { "cell_type": "markdown", "id": "675ea593", "metadata": {}, "source": [ "# pdf011_Student\n", "Tutorial illustrating the use of the Student and F distributions\n", "\n", "\n", "\n", "\n", "**Author:** Anna Kreshuk \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:26 PM." ] }, { "cell_type": "markdown", "id": "7cb6fe7d", "metadata": {}, "source": [ "drawing the set of student density functions\n", "normal(0, 1) density drawn for comparison" ] }, { "cell_type": "code", "execution_count": 1, "id": "67f4653b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:57.159715Z", "iopub.status.busy": "2026-05-19T20:26:57.159584Z", "iopub.status.idle": "2026-05-19T20:26:57.618565Z", "shell.execute_reply": "2026-05-19T20:26:57.617775Z" } }, "outputs": [], "source": [ "TCanvas *DistCanvas = new TCanvas(\"DistCanvas\", \"Distribution graphs\", 10, 10, 800, 650);\n", "DistCanvas->SetFillColor(17);\n", "DistCanvas->Divide(2, 2);\n", "DistCanvas->cd(1);\n", "gPad->SetGrid();\n", "gPad->SetFrameFillColor(19);\n", "TLegend *leg = new TLegend(0.6, 0.7, 0.89, 0.89);\n", "\n", "\n", "TF1* fgaus = new TF1(\"gaus\", \"TMath::Gaus(x, [0], [1], [2])\", -5, 5);\n", "fgaus->SetTitle(\"Student density\");\n", "fgaus->SetLineStyle(kDashed);\n", "fgaus->SetLineWidth(1);\n", "fgaus->SetParameters(0, 1, kTRUE);\n", "leg->AddEntry(fgaus->DrawCopy(), \"Normal(0,1)\", \"l\");\n", "\n", "TF1* student = new TF1(\"student\", \"TMath::Student(x,[0])\", -5, 5);" ] }, { "cell_type": "markdown", "id": "46cf8883", "metadata": {}, "source": [ "student->SetTitle(\"Student density\");" ] }, { "cell_type": "code", "execution_count": 2, "id": "bcc4b235", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:57.620301Z", "iopub.status.busy": "2026-05-19T20:26:57.620180Z", "iopub.status.idle": "2026-05-19T20:26:57.827244Z", "shell.execute_reply": "2026-05-19T20:26:57.826542Z" } }, "outputs": [], "source": [ "student->SetLineWidth(1);\n", "student->SetParameter(0, 10);\n", "student->SetLineColor(4);\n", "leg->AddEntry(student->DrawCopy(\"lsame\"), \"10 degrees of freedom\", \"l\");\n", "\n", "student->SetParameter(0, 3);\n", "student->SetLineColor(2);\n", "leg->AddEntry(student->DrawCopy(\"lsame\"), \"3 degrees of freedom\", \"l\");\n", "\n", "student->SetParameter(0, 1);\n", "student->SetLineColor(1);\n", "leg->AddEntry(student->DrawCopy(\"lsame\"), \"1 degree of freedom\", \"l\");\n", "\n", "leg->Draw();" ] }, { "cell_type": "markdown", "id": "3dba7ac6", "metadata": {}, "source": [ "drawing the set of student cumulative probability functions" ] }, { "cell_type": "code", "execution_count": 3, "id": "d9c673a1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:57.829200Z", "iopub.status.busy": "2026-05-19T20:26:57.829082Z", "iopub.status.idle": "2026-05-19T20:26:58.036124Z", "shell.execute_reply": "2026-05-19T20:26:58.035340Z" } }, "outputs": [], "source": [ "DistCanvas->cd(2);\n", "gPad->SetFrameFillColor(19);\n", "gPad->SetGrid();\n", "TF1 *studentI = new TF1(\"studentI\", \"TMath::StudentI(x, [0])\", -5, 5);\n", "studentI->SetTitle(\"Student cumulative dist.\");\n", "studentI->SetLineWidth(1);\n", "TLegend *leg2 = new TLegend(0.6, 0.4, 0.89, 0.6);\n", "\n", "studentI->SetParameter(0, 10);\n", "studentI->SetLineColor(4);\n", "leg2->AddEntry(studentI->DrawCopy(), \"10 degrees of freedom\", \"l\");\n", "\n", "studentI->SetParameter(0, 3);\n", "studentI->SetLineColor(2);\n", "leg2->AddEntry(studentI->DrawCopy(\"lsame\"), \"3 degrees of freedom\", \"l\");\n", "\n", "studentI->SetParameter(0, 1);\n", "studentI->SetLineColor(1);\n", "leg2->AddEntry(studentI->DrawCopy(\"lsame\"), \"1 degree of freedom\", \"l\");\n", "leg2->Draw();" ] }, { "cell_type": "markdown", "id": "b4349d98", "metadata": {}, "source": [ "drawing the set of F-dist. densities" ] }, { "cell_type": "code", "execution_count": 4, "id": "63a6f8b7", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:58.037899Z", "iopub.status.busy": "2026-05-19T20:26:58.037780Z", "iopub.status.idle": "2026-05-19T20:26:58.244624Z", "shell.execute_reply": "2026-05-19T20:26:58.243981Z" } }, "outputs": [], "source": [ "TF1* fDist = new TF1(\"fDist\", \"TMath::FDist(x, [0], [1])\", 0, 2);\n", "fDist->SetTitle(\"F-Dist. density\");\n", "fDist->SetLineWidth(1);\n", "TLegend* legF1 = new TLegend(0.7, 0.7, 0.89, 0.89);\n", "\n", "DistCanvas->cd(3);\n", "gPad->SetFrameFillColor(19);\n", "gPad->SetGrid();\n", "\n", "fDist->SetParameters(1, 1);\n", "fDist->SetLineColor(1);\n", "legF1->AddEntry(fDist->DrawCopy(), \"N=1 M=1\", \"l\");\n", "\n", "fDist->SetParameter(1, 10);\n", "fDist->SetLineColor(2);\n", "legF1->AddEntry(fDist->DrawCopy(\"lsame\"), \"N=1 M=10\", \"l\");\n", "\n", "fDist->SetParameters(10, 1);\n", "fDist->SetLineColor(8);\n", "legF1->AddEntry(fDist->DrawCopy(\"lsame\"), \"N=10 M=1\", \"l\");\n", "\n", "fDist->SetParameters(10, 10);\n", "fDist->SetLineColor(4);\n", "legF1->AddEntry(fDist->DrawCopy(\"lsame\"), \"N=10 M=10\", \"l\");\n", "\n", "legF1->Draw();" ] }, { "cell_type": "markdown", "id": "80402dcb", "metadata": {}, "source": [ "drawing the set of F cumulative dist.functions" ] }, { "cell_type": "code", "execution_count": 5, "id": "daeada02", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:58.246743Z", "iopub.status.busy": "2026-05-19T20:26:58.246619Z", "iopub.status.idle": "2026-05-19T20:26:58.453200Z", "shell.execute_reply": "2026-05-19T20:26:58.452778Z" } }, "outputs": [], "source": [ "TF1* fDistI = new TF1(\"fDist\", \"TMath::FDistI(x, [0], [1])\", 0, 2);\n", "fDistI->SetTitle(\"Cumulative dist. function for F\");\n", "fDistI->SetLineWidth(1);\n", "TLegend* legF2 = new TLegend(0.7, 0.3, 0.89, 0.5);\n", "\n", "DistCanvas->cd(4);\n", "gPad->SetFrameFillColor(19);\n", "gPad->SetGrid();\n", "fDistI->SetParameters(1, 1);\n", "fDistI->SetLineColor(1);\n", "legF2->AddEntry(fDistI->DrawCopy(), \"N=1 M=1\", \"l\");\n", "\n", "fDistI->SetParameters(1, 10);\n", "fDistI->SetLineColor(2);\n", "legF2->AddEntry(fDistI->DrawCopy(\"lsame\"), \"N=1 M=10\", \"l\");\n", "\n", "fDistI->SetParameters(10, 1);\n", "fDistI->SetLineColor(8);\n", "legF2->AddEntry(fDistI->DrawCopy(\"lsame\"), \"N=10 M=1\", \"l\");\n", "\n", "fDistI->SetParameters(10, 10);\n", "fDistI->SetLineColor(4);\n", "legF2->AddEntry(fDistI->DrawCopy(\"lsame\"), \"N=10 M=10\", \"l\");\n", "\n", "legF2->Draw();\n", "DistCanvas->cd();" ] }, { "cell_type": "markdown", "id": "30c4c33f", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 6, "id": "e48d5942", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:58.455154Z", "iopub.status.busy": "2026-05-19T20:26:58.455044Z", "iopub.status.idle": "2026-05-19T20:26:58.767413Z", "shell.execute_reply": "2026-05-19T20:26:58.766955Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "