ROOT
Version master
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
fitConvolution.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_fit
3
## \notebook
4
## Tutorial for convolution of two functions
5
##
6
## \macro_image
7
## \macro_output
8
## \macro_code
9
##
10
## \author Jonas Rembser, Aurelie Flandi (C++ version)
11
12
import
ROOT
13
import
numpy
as
np
14
15
# Construction of histogram to fit.
16
h_ExpGauss =
ROOT.TH1F
(
"h_ExpGauss"
,
"Exponential convoluted by Gaussian"
, 100, 0.0, 5.0)
17
h_ExpGauss.Fill
(
18
np.array
(
19
[
20
# Gives a alpha of -0.3 in the exp.
21
# Probability density function of the addition of two variables is the
22
# convolution of two density functions.
23
ROOT.gRandom.Exp
(1.0 / 0.3) +
ROOT.gRandom.Gaus
(0.0, 3.0)
24
for
_
in
range
(1000000)
25
]
26
)
27
)
28
f_conv =
ROOT.TF1Convolution
(
"expo"
,
"gaus"
, -1, 6,
True
)
29
f_conv.SetRange
(-1.0, 6.0)
30
f_conv.SetNofPointsFFT
(1000)
31
f =
ROOT.TF1
(
"f"
, f_conv, 0.0, 5.0,
f_conv.GetNpar
())
32
f.SetParameters
(1.0, -0.3, 0.0, 1.0)
33
34
c1 =
ROOT.TCanvas
(
"c1"
,
"c1"
, 800, 1000)
35
36
# Fit and draw result of the fit
37
h_ExpGauss.Fit
(
"f"
)
38
39
c1.SaveAs
(
"fitConvolution.png"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
tutorials
math
fit
fitConvolution.py
ROOT master - Reference Guide Generated on Sat Apr 26 2025 15:41:10 (GVA Time) using Doxygen 1.10.0