hurst_exponent
Builtin index · Signal processing
result = hurst_exponent(x)
Input: x · Output: result
What it is
x: a length-N real vector.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = hurst_exponent(x) | x vectornot documented yet | result number | Returns a single number: 0.5 is a random walk, above that persistent, below it mean-reverting — long-range dependence. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
fs = 1000
n = 0:1:511
t = n / fs
x = sin(2*pi*20*t) + 0.2*randn(512, seed=4)
r = acf(x, max_lag=50)
below = find_peaks(-abs(r - 1/e))
print("acf[0] = {r[0]}, acf drops below 1/e near lag {below[0]}")
h_tone = hurst_exponent(x)
h_walk = hurst_exponent(cumsum(randn(512, seed=5)))
print("hurst (periodic+noise) = {h_tone}, hurst (random walk) = {h_walk}")
output
acf[0] = 1, acf drops below 1/e near lag 9 hurst (periodic+noise) = 0.71599, hurst (random walk) = 0.998318
from signal-processing
How it works
hurst_exponent(x) — see the free function's own doc comment for the R/S-analysis algorithm and how to read the result (persistent/random-walk/anti-persistent).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.