LIVE
connecting to the live quote stream…
--:--:--UTC
easyML○
#27

Regime split by VIX median

easyMLacceptance —~15 min

Implement regime(vix, window) — for every day t >= window, flag 1 if the VIX close is STRICTLY above the median of the previous window closes (vix[t - window : t], excluding today), else 0. Return the list of flags, one per day from t = window onward.

The regime model in ai quants routes each day to a high-vol or low-vol specialist on exactly this switch. Use statistics.median.

example 1
input
vix=[15.0, 16.0, 14.0, 17.0, 13.0, 18.0], window=3
output
[1, 0, 1]
example 2
input
vix=[15.0, 16.0, 14.0, 15.0, 13.0, 18.0], window=3
output
[0, 0, 1]
note

Day 3 equals its trailing median exactly — that is a 0.

constraints
  • window + 1 ≤ len(vix) ≤ 10_000
  • 1 ≤ window ≤ 120
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 regime()
vix=[15.0, 16.0, 14.0, 17.0, 13.0, 18.0], window=3
expected
[1, 0, 1]

the judge calls regime() 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