Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
mathBeta.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Test the TMath::BetaDist and TMath::BetaDistI functions

#include "TMath.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TLegend.h"
void mathBeta() {
TCanvas *c1=new TCanvas("c1", "TMath::BetaDist",600,800);
c1->Divide(1, 2);
TVirtualPad *pad1 = c1->cd(1);
pad1->SetGrid();
TF1 *fbeta = new TF1("fbeta", "TMath::BetaDist(x, [0], [1])", 0, 1);
fbeta->SetParameters(0.5, 0.5);
TF1 *f1 = fbeta->DrawCopy();
fbeta->SetParameters(0.5, 2);
TF1 *f2 = fbeta->DrawCopy("same");
f2->SetLineWidth(1);
fbeta->SetParameters(2, 0.5);
TF1 *f3 = fbeta->DrawCopy("same");
f3->SetLineWidth(1);
fbeta->SetParameters(2, 2);
TF1 *f4 = fbeta->DrawCopy("same");
f4->SetLineWidth(1);
TLegend *legend1 = new TLegend(.5,.7,.8,.9);
legend1->AddEntry(f1,"p=0.5 q=0.5","l");
legend1->AddEntry(f2,"p=0.5 q=2","l");
legend1->AddEntry(f3,"p=2 q=0.5","l");
legend1->AddEntry(f4,"p=2 q=2","l");
legend1->Draw();
TVirtualPad *pad2 = c1->cd(2);
pad2->SetGrid();
TF1 *fbetai=new TF1("fbetai", "TMath::BetaDistI(x, [0], [1])", 0, 1);
fbetai->SetParameters(0.5, 0.5);
TF1 *g1=fbetai->DrawCopy();
g1->SetLineWidth(1);
fbetai->SetParameters(0.5, 2);
TF1 *g2=fbetai->DrawCopy("same");
g2->SetLineWidth(1);
fbetai->SetParameters(2, 0.5);
TF1 *g3=fbetai->DrawCopy("same");
g3->SetLineWidth(1);
fbetai->SetParameters(2, 2);
TF1 *g4=fbetai->DrawCopy("same");
g4->SetLineWidth(1);
TLegend *legend2 = new TLegend(.7,.15,0.9,.35);
legend2->AddEntry(f1,"p=0.5 q=0.5","l");
legend2->AddEntry(f2,"p=0.5 q=2","l");
legend2->AddEntry(f3,"p=2 q=0.5","l");
legend2->AddEntry(f4,"p=2 q=2","l");
legend2->Draw();
c1->cd();
}
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kMagenta
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
The Canvas class.
Definition TCanvas.h:23
1-Dim function class
Definition TF1.h:233
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes.
Definition TF1.cxx:1365
virtual void SetParameters(const Double_t *params)
Definition TF1.h:670
This class displays a legend box (TPaveText) containing several legend entries.
Definition TLegend.h:23
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
Definition TLegend.cxx:317
void Draw(Option_t *option="") override
Draw this legend with its current attributes.
Definition TLegend.cxx:422
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
return c1
Definition legend1.C:41
TF1 * f1
Definition legend1.C:11
Author
Anna Kreshuk

Definition in file mathBeta.C.