From $ROOTSYS/tutorials/math/tStudent.C

// Example macro describing the student t distribution
//
// root[0]: .x tStudent.C
//
// It draws the pdf, the cdf and then 10 quantiles of the t Student distribution
//
// Author: Magdalena Slawinska

#include "TH1.h"
#include "TF1.h"
#include "TCanvas.h"
#include "TSystem.h"
#include "TLegend.h"
#include "TLegendEntry.h"
#include "Math/DistFunc.h"


void tStudent()
{

   //gSystem->Load("libMathMore");
   // this is the way to force load of MathMore in Cling
   ROOT::Math::MathMoreLibrary::Load();

   int n=100;
   double a=-5.;
   double b=5.;
   //double r  = 3;
   TF1* pdf = new TF1("pdf", "ROOT::Math::tdistribution_pdf(x,3.0)", a,b);
   TF1* cum = new TF1("cum", "ROOT::Math::tdistribution_cdf(x,3.0)", a,b);

   TH1D* quant = new TH1D("quant", "", 9, 0, 0.9);

   for(int i=1; i < 10; i++)
      quant->Fill((i-0.5)/10.0, ROOT::Math::tdistribution_quantile((1.0*i)/10, 3.0 ) );

   double xx[10];
   xx[0] = -1.5;
   for(int i=1; i<9; i++)
      xx[i]= quant->GetBinContent(i);
   xx[9] = 1.5;
   TH1D* pdfq[10];
   //int nbin = n/10.0;
   for(int i=0; i < 9; i++) {
      int nbin = n * (xx[i+1]-xx[i])/3.0 + 1.0;
      TString name = "pdf";
      name += i;
      pdfq[i]= new TH1D(name, "", nbin,xx[i],xx[i+1] );
      for(int j=1; j<nbin; j++) {
         double x= j*(xx[i+1]-xx[i])/nbin + xx[i];
         pdfq[i]->SetBinContent(j, ROOT::Math::tdistribution_pdf(x,3));
      }
   }

   TCanvas *Canvas = new TCanvas("DistCanvas", "Student Distribution graphs", 10, 10, 1000, 800);
   pdf->SetTitle("Student t distribution function");
   cum->SetTitle("Cumulative for Student t");
   quant->SetTitle("10-quantiles  for Student t");
   Canvas->Divide(2, 2);
   Canvas->cd(1);
   pdf->SetLineWidth(2);
   pdf->DrawCopy();
   Canvas->cd(2);
   cum->SetLineWidth(2);
   cum->SetLineColor(kRed);
   cum->Draw();
   Canvas->cd(3);
   quant->Draw();
   quant->SetLineWidth(2);
   quant->SetLineColor(kBlue);
   quant->SetStats(0);
   Canvas->cd(4);
   pdfq[0]->SetTitle("Student t & its quantiles");
   pdf->SetTitle("");
   pdf->Draw();
   //pdfq[0]->SetAxisRange(-1.5, 0, 1.5,1.0);
   pdfq[0]->SetTitle("Student t & its quantiles");
   for(int i=0; i < 9; i++) {
      pdfq[i]->SetStats(0);
      pdfq[i]->SetFillColor(i+1);
      pdfq[i]->Draw("same");
   }
   Canvas->Modified();
   Canvas->cd();
}
 tStudent.C:1
 tStudent.C:2
 tStudent.C:3
 tStudent.C:4
 tStudent.C:5
 tStudent.C:6
 tStudent.C:7
 tStudent.C:8
 tStudent.C:9
 tStudent.C:10
 tStudent.C:11
 tStudent.C:12
 tStudent.C:13
 tStudent.C:14
 tStudent.C:15
 tStudent.C:16
 tStudent.C:17
 tStudent.C:18
 tStudent.C:19
 tStudent.C:20
 tStudent.C:21
 tStudent.C:22
 tStudent.C:23
 tStudent.C:24
 tStudent.C:25
 tStudent.C:26
 tStudent.C:27
 tStudent.C:28
 tStudent.C:29
 tStudent.C:30
 tStudent.C:31
 tStudent.C:32
 tStudent.C:33
 tStudent.C:34
 tStudent.C:35
 tStudent.C:36
 tStudent.C:37
 tStudent.C:38
 tStudent.C:39
 tStudent.C:40
 tStudent.C:41
 tStudent.C:42
 tStudent.C:43
 tStudent.C:44
 tStudent.C:45
 tStudent.C:46
 tStudent.C:47
 tStudent.C:48
 tStudent.C:49
 tStudent.C:50
 tStudent.C:51
 tStudent.C:52
 tStudent.C:53
 tStudent.C:54
 tStudent.C:55
 tStudent.C:56
 tStudent.C:57
 tStudent.C:58
 tStudent.C:59
 tStudent.C:60
 tStudent.C:61
 tStudent.C:62
 tStudent.C:63
 tStudent.C:64
 tStudent.C:65
 tStudent.C:66
 tStudent.C:67
 tStudent.C:68
 tStudent.C:69
 tStudent.C:70
 tStudent.C:71
 tStudent.C:72
 tStudent.C:73
 tStudent.C:74
 tStudent.C:75
 tStudent.C:76
 tStudent.C:77
 tStudent.C:78
 tStudent.C:79
 tStudent.C:80
 tStudent.C:81
 tStudent.C:82
 tStudent.C:83
 tStudent.C:84
 tStudent.C:85
 tStudent.C:86