-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmontecarloDistribution.py
36 lines (26 loc) · 995 Bytes
/
montecarloDistribution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
montecarloDistribution.py
Created by Luca Camerani at 12/09/2020, University of Milano-Bicocca.
All rights reserved.
This file is part of the EcoFin-Library (https://github.com/LucaCamerani/EcoFin-Library),
and is released under the "BSD Open Source License".
"""
import matplotlib.pyplot as plt
from EcoFin.math.stochasticProcess.itoProcess import ItoProcess
from EcoFin.stat.montecarloDistribution import MonteCarlo
t = 20
T = 100
dt = 1
n = 3000
index = 30
ito = ItoProcess(T, dt, t=t, x0=100, n=n)
# ---[GEOMETRIC BROWNIAN MOTION]----------------------------------------------
simulation = ito.geometricBrownianMotion(0.01, 0.02)
# ----------------------------------------------------------------------------
MC = MonteCarlo(simulation)
EPDF = MC.getEmpiricalDist(bandwidth=10, index=index)
plt.hist(MC.getData(index=index), density=True, bins=50, label='Histogram')
plt.plot(EPDF.values, EPDF.probabilities, label='EPDF')
plt.legend()
plt.show()