# 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_times(n_good, hurst_func_good, length_good, mbm_method_good): m = MBM(n_good, hurst_func_good, length_good, mbm_method_good) ts = m.times() assert isinstance(ts, np.ndarray) assert len(ts) == n_good + 1
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)