import src.fBm_plot as pfb
from importlib import reload
reload(pfb)
import matplotlib.pyplot as plt
import warnings
import numpy as np
warnings.filterwarnings('ignore')The fBm is a generalization of the ordinary Brownian motion (oBm) that accounts for memory effects and long-term correlations. There exist many definitions, one of particular utility is given by [1],
where
and
-
$H = 1/2$ , retrieves oBm$B(t) \equiv B_{1/2}(t)$ , with
and transition probability (or propagator),
-
$H > 1/2$ , gives positevely correlated increments -
$H < 1/2$ , gives negatively correlated increments.
The definition of the fBm can also be expressed as a Riemann-Liouville fractional integral,
The construction of the propagator for the fBm can be achieved by using the path integral summing over the trajectories
The formal solution of this propagator is given by [1],
In the Figure below, the PDF of the fBm is shown for 20.000 trajectories and different points of time. It was fitted using the previous expression (including all the coefficientes).
[1] Calvo I. and Sánchez R. The path integral formulation of fractional Brownian motion for the general Hurst exponent. J. Phys. A: Math. Theor. 41 (2008)
import src.fBm_utils as fbm
T = 10
dt = 0.1
H = 0.7
n = int(T/dt)
fbm_series = fbm.get_realizations(H, T, n, 20000)[0]
fig, ax = plt.subplots()
pfb.plot_pdf_fBm(ax, H, t = 1.0, fbm_series = fbm_series)
pfb.plot_pdf_fBm(ax, H, t = 3.0, fbm_series = fbm_series)
pfb.plot_pdf_fBm(ax, H, t = 5.0, fbm_series = fbm_series)
fig.legend()
ax.set_title("")Text(0.5, 1.0, '')
From the solution of the propagator, we can see that the fBm is distributed as a Gaussian with variance
Note that {fbm0.0.3} returns an fBm with normalized variance, sunch that
This analytical expression is compared with an average over 20.000 trajectories generated with the library in the plot below.
t_ref = 5
fig, ax = plt.subplots(2, 2, figsize=(7,7))
H = 0.2
pfb.plot_msd_fBm(ax[0][0], H)
H = 0.5
pfb.plot_msd_fBm(ax[0][1], H)
H = 0.7
pfb.plot_msd_fBm(ax[1][0], H)
H = 0.9
pfb.plot_msd_fBm(ax[1][1], H)
fig.tight_layout()
handles, labels = ax[0][0].get_legend_handles_labels()
fig.legend(handles, labels, bbox_to_anchor = (0.99, -0.03), ncol = 2);100%|██████████| 20000/20000 [00:33<00:00, 604.10it/s]
100%|██████████| 20000/20000 [00:16<00:00, 1193.20it/s]
100%|██████████| 20000/20000 [00:32<00:00, 613.00it/s]
100%|██████████| 20000/20000 [02:40<00:00, 124.87it/s]
For a normalized fBm, the (auto)-covariance between two times
t_ref = 5
fig, ax = plt.subplots(2, 2, figsize=(7,7))
H = 0.2
pfb.plot_cov_fBm(ax[0][0], H, t_ref)
H = 0.5
pfb.plot_cov_fBm(ax[0][1], H, t_ref)
H = 0.7
pfb.plot_cov_fBm(ax[1][0], H, t_ref)
H = 0.9
pfb.plot_cov_fBm(ax[1][1], H, t_ref)
fig.tight_layout()
handles, labels = ax[0][0].get_legend_handles_labels()
fig.legend(handles, labels, bbox_to_anchor = (0.99, -0.03), ncol = 4)
fig.show()100%|██████████| 20000/20000 [00:34<00:00, 585.66it/s]
100%|██████████| 20000/20000 [00:17<00:00, 1146.68it/s]
100%|██████████| 20000/20000 [00:31<00:00, 628.97it/s]
100%|██████████| 20000/20000 [02:33<00:00, 130.70it/s]
t_ref = 5
fig, ax = plt.subplots(2, 2, figsize=(7,7))
H = 0.2
pfb.plot_cov_noise(ax[0][0], H, t_ref)
H = 0.5
pfb.plot_cov_noise(ax[0][1], H, t_ref)
H = 0.7
pfb.plot_cov_noise(ax[1][0], H, t_ref)
H = 0.9
pfb.plot_cov_noise(ax[1][1], H, t_ref)
fig.tight_layout()
handles, labels = ax[0][0].get_legend_handles_labels()
fig.legend(handles, labels, bbox_to_anchor = (0.99, -0.03), ncol = 4)
fig.show()100%|██████████| 10000/10000 [00:13<00:00, 746.13it/s]
100%|██████████| 10000/10000 [00:04<00:00, 2248.56it/s]
100%|██████████| 10000/10000 [00:12<00:00, 777.16it/s]
100%|██████████| 10000/10000 [01:12<00:00, 137.27it/s]



