Created
February 25, 2021 10:12
-
-
Save Steboss/a6d7d828323f18234c8b1a06832039b7 to your computer and use it in GitHub Desktop.
Compute Hurst exponent from RMS-log2 transform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What we have computed are the fluctuations | |
// now we can retrieve the Hurst exponent via a polyfit again | |
float* log2_scales ; | |
// create a log2 x-axis | |
log2_scales = (float*)malloc(scales_len*sizeof(float)); | |
for(int h=0; h<scales_len;h++){ | |
log2_scales[h]= Log2( (float)scales[h]); | |
} | |
// transform the RMS (fluctuations) with log2 | |
float* log2_fluct ; | |
log2_fluct = (float*)malloc(scales_len*sizeof(float)); | |
for(int h=0; h<scales_len;h++){ | |
log2_fluct[h]= Log2(rms[h]); | |
} | |
// Fit log2 x-axis with log2 fluctuations | |
polyfit(log2_scales, | |
log2_fluct, | |
scales_len, | |
fitting_order, | |
coeffs | |
); | |
// return the RMS to fluct Cython memview | |
for (int h=0; h<scales_len;h++){ | |
fluct[h] = rms[h]; | |
} | |
// Hurst exponent is coeffs[1] | |
// Free everything | |
free (tmpCoeff); | |
free(Xcumsum); | |
free(rms); | |
free(log2_fluct); | |
free(log2_scales); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment