ROOT
v6-36
Reference Guide
Loading...
Searching...
No Matches
pdf000_Laplace.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_pdf
3
/// \notebook
4
/// Test the TMath::LaplaceDist and TMath::LaplaceDistI functions
5
///
6
/// \macro_image
7
/// \macro_code
8
///
9
/// \author Anna Kreshuk
10
11
#include "
TMath.h
"
12
#include "
TCanvas.h
"
13
#include "
TF1.h
"
14
#include "
TLegend.h
"
15
16
void
pdf000_Laplace
(){
17
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"TMath::LaplaceDist"
,600,800);
18
c1
->Divide(1, 2);
19
TVirtualPad
*
pad1
=
c1
->cd(1);
20
pad1
->SetGrid();
21
TF1
*
flaplace
=
new
TF1
(
"flaplace"
,
"TMath::LaplaceDist(x, [0], [1])"
, -10, 10);
22
flaplace
->SetParameters(0, 1);
23
TF1
*
f1
=
flaplace
->DrawCopy();
24
f1
->
SetLineColor
(
kRed
);
25
f1
->
SetLineWidth
(1);
26
flaplace
->SetParameters(0, 2);
27
TF1
*f2 =
flaplace
->DrawCopy(
"same"
);
28
f2->
SetLineColor
(
kGreen
);
29
f2->
SetLineWidth
(1);
30
flaplace
->SetParameters(2, 1);
31
TF1
*f3 =
flaplace
->DrawCopy(
"same"
);
32
f3->
SetLineColor
(
kBlue
);
33
f3->
SetLineWidth
(1);
34
flaplace
->SetParameters(2, 2);
35
TF1
*f4 =
flaplace
->DrawCopy(
"same"
);
36
f4->
SetLineColor
(
kMagenta
);
37
f4->
SetLineWidth
(1);
38
TLegend
*
legend1
=
new
TLegend
(.7,.7,.9,.9);
39
legend1
->AddEntry(
f1
,
"alpha=0 beta=1"
,
"l"
);
40
legend1
->AddEntry(f2,
"alpha=0 beta=2"
,
"l"
);
41
legend1
->AddEntry(f3,
"alpha=2 beta=1"
,
"l"
);
42
legend1
->AddEntry(f4,
"alpha=2 beta=2"
,
"l"
);
43
legend1
->Draw();
44
45
TVirtualPad
*
pad2
=
c1
->cd(2);
46
pad2
->SetGrid();
47
TF1
*
flaplacei
=
new
TF1
(
"flaplacei"
,
"TMath::LaplaceDistI(x, [0], [1])"
, -10, 10);
48
flaplacei
->SetParameters(0, 1);
49
TF1
*
g1
=
flaplacei
->DrawCopy();
50
g1
->SetLineColor(
kRed
);
51
g1
->SetLineWidth(1);
52
flaplacei
->SetParameters(0, 2);
53
TF1
*
g2
=
flaplacei
->DrawCopy(
"same"
);
54
g2
->SetLineColor(
kGreen
);
55
g2
->SetLineWidth(1);
56
flaplacei
->SetParameters(2, 1);
57
TF1
*
g3
=
flaplacei
->DrawCopy(
"same"
);
58
g3
->SetLineColor(
kBlue
);
59
g3
->SetLineWidth(1);
60
flaplacei
->SetParameters(2, 2);
61
TF1
*
g4
=
flaplacei
->DrawCopy(
"same"
);
62
g4
->SetLineColor(
kMagenta
);
63
g4
->SetLineWidth(1);
64
65
TLegend
*
legend2
=
new
TLegend
(.7,.15,0.9,.35);
66
legend2
->AddEntry(
f1
,
"alpha=0 beta=1"
,
"l"
);
67
legend2
->AddEntry(f2,
"alpha=0 beta=2"
,
"l"
);
68
legend2
->AddEntry(f3,
"alpha=2 beta=1"
,
"l"
);
69
legend2
->AddEntry(f4,
"alpha=2 beta=2"
,
"l"
);
70
legend2
->Draw();
71
c1
->cd();
72
}
kRed
@ kRed
Definition
Rtypes.h:66
kGreen
@ kGreen
Definition
Rtypes.h:66
kMagenta
@ kMagenta
Definition
Rtypes.h:66
kBlue
@ kBlue
Definition
Rtypes.h:66
TCanvas.h
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TF1.h
TLegend.h
TMath.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition
TAttLine.h:45
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition
TAttLine.h:42
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF1
1-Dim function class
Definition
TF1.h:234
TLegend
This class displays a legend box (TPaveText) containing several legend entries.
Definition
TLegend.h:23
TVirtualPad
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition
TVirtualPad.h:51
c1
return c1
Definition
legend1.C:41
f1
TF1 * f1
Definition
legend1.C:11
tutorials
math
pdf
pdf000_Laplace.C
ROOT v6-36 - Reference Guide Generated on Thu Aug 21 2025 04:30:47 (GVA Time) using Doxygen 1.10.0