Skip to content

Instantly share code, notes, and snippets.

@Steboss
Created February 25, 2021 10:32
Show Gist options
  • Save Steboss/e153114fd882304aa046d721b8f4c7b1 to your computer and use it in GitHub Desktop.
Save Steboss/e153114fd882304aa046d721b8f4c7b1 to your computer and use it in GitHub Desktop.
Return values and plot RMS and get Hurst coefficients
scales, fluct_to_array, coeff_to_array= dfa.play(X,5,9,0.25)
print("Fluctuations")
print(fluct_to_array)
print("Coefficients, swapped")
print(coeff_to_array)
#we need to swap the order here, due to the way coeff are computed!
coeff_tmp = coeff_to_array[1]
coeff_to_array[1] = coeff_to_array[0]
coeff_to_array[0] = coeff_tmp
fluctfit = 2**np.polyval(coeff_to_array,np.log2(scales))
plt.loglog(scales, fluct_to_array, 'bo')
plt.loglog(scales, fluctfit, 'r', label=r'$\alpha$ = %0.2f'%coeff_to_array[0])
plt.title('DFA')
plt.xlabel(r'$\log_{10}$(time window)')
plt.ylabel(r'$\log_{10}$<F(t)>')#
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment