def test_MBM_mbm(n_good, hurst_func_good, length_good, mbm_method_good):
    m = MBM(n_good, hurst_func_good, length_good, mbm_method_good)
    mbm_sample = m.mbm()
    assert isinstance(mbm_sample, np.ndarray)
    assert len(mbm_sample) == n_good + 1
# flake8: noqa
from fbm import MBM
import matplotlib.pyplot as plt
import time
import math


def h(t):
    # return 0.499*math.sin(t) + 0.5
    # return 0.6 * t + 0.3
    return 0.5 * math.exp(-8 * t**2) + 0.35


m = MBM(2**8, h, 1)
t = m.times()
mbm = m.mbm()

plt.plot(t, mbm)
plt.plot(t, [h(tt) for tt in t])
plt.show()
def test_MBM_change(n_good, hurst_func_good, length_good, mbm_method_good):
    m = MBM(n_good, hurst_func_good, length_good, mbm_method_good)
    m.n = 42
    assert m._changed == True
    sample = m.mbm()
    assert m._changed == False
Exemple #4
0
    return hurst[t]


m = MBM(n=size, hurst=H, length=1)

#m0 = MBM(1024, h0)
#m1 = MBM(1024, h1)
#m2 = MBM(1024, h2)

fig = plt.figure()

ax1 = fig.add_subplot(2, 1, 1)
ax2 = fig.add_subplot(2, 1, 2)

ax1.set_title(r'MBM simulation for BTC prices', )
ax1.plot(m.times(), m.mbm(), 'r')
ax2.set_title(r'Hurst function')
ax2.plot(m.times(), Hplot(m.times()), 'r')
ax2.set_yticks(np.arange(0.35, 0.6, 0.05))
ax2.set_xticks(np.arange(0, 1.01, 0.1))
ax1.set_xticks(np.arange(0, 1.01, 0.1))
ax1.set_xlim([0, 1])
ax2.set_xlim([0, 1])
ax2.set_ylim([0.3, 0.6])

fig.show()
fig.tight_layout()

#fig.savefig('MBM_simulation.png', format='png', dpi=1000)

#fig0 = plt.figure(0)