LIVE
connecting to the live quote stream…
--:--:--UTC
hardQuant○
#13

Hurst exponent by R/S

hardQuantacceptance —~40 min

Implement hurst_rs(returns) — the rescaled-range estimate of the Hurst exponent on a single window: subtract the mean from the series, cumulate the deviations, take R = max - min of the cumulative series and S the population standard deviation of the original series, and return H = log(R / S) / log(n).

H near 0.5 is a random walk, above it trends persist, below it they revert — the regime call the workbench's Hurst bot makes. Return H rounded to 4 decimal places.

example 1
input
returns=[0.01, -0.01, 0.02, -0.02, 0.015, -0.015, 0.005, -0.005]
output
0.1822
example 2
input
returns=[0.01, 0.02, 0.015, 0.03, 0.005, 0.01, 0.02, 0.025]
output
0.4168
note

A trending series: every return is positive, so the mean is not zero and it matters.

constraints
  • 8 ≤ len(returns) ≤ 5_000
  • S > 0
teacher · 2 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to hurst_rs()
returns=[0.01, -0.01, 0.02, -0.02, 0.015, -0.015, 0.005, -0.005]
expected
0.1822

the judge calls hurst_rs() with exactly these inputs · outputs are compared to 6 decimal places

● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice