Given a stream of data, how would you implement a sliding window filter to detect anomalies?
Implement detect_anomalies(data, window_size, threshold). For each value, compare it with the mean of up to the previous window_size values. Return an array of zero-based indices where the absolute difference is greater than threshold; values without prior observations are never anomalous.
def detect_anomalies(data, window_size, threshold):