Rolling Z-Score
Xem dạng PDF
Gửi bài giải
Điểm:
100,00
Giới hạn thời gian:
2.0s
Giới hạn bộ nhớ:
256M
Tác giả:
Dạng bài
Ngôn ngữ cho phép
Python
Task
For each position i from w-1 to n-1, compute the z-score of x[i] relative to the window x[i-w+1 : i+1] (population std, ddof=0). If std = 0 for a window, output 0 for that position.
Input
- Line 1: two ints
n w - Line 2:
nspace-separated floats
Output
n - w + 1 space-separated floats (10 significant digits).
Example
Input:
6 3
1 3 5 4 2 6
Output:
1.069044968 0 -0.5345224838 1.069044968
Scaffolding
def rolling_zscore(x: list[float], w: int) -> list[float]: ...
Notes
Track A: the last element of each window is the point being scored. A spike shows as |z| > 2–3 — the basis of online anomaly detection.
Bình luận