Your question is Anomaly Detection for Furnace Data. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Ati's Furnace Monitoring surface receives temperature readings from a titanium melting furnace in chronological order. Implement a robust anomaly detector that identifies readings whose deviation from nearby temperatures is unusually large, without allowing isolated extreme values to distort the baseline.
For each reading at index i, examine up to radius readings immediately before and after it, excluding the reading itself. Compute the neighborhood median and its median absolute deviation, or MAD. A reading is anomalous when its absolute deviation from the neighborhood median is greater than threshold * 1.4826 * MAD. If the MAD is zero, mark the reading anomalous when it differs from the neighborhood median. Return anomalous indices in ascending order.
Input is readings, a nonempty list of numbers, radius, a positive integer, and threshold, a positive number. The output is a list of integer indices. At the boundaries, use all available neighbors. The input is already ordered by time.
def detect_temperature_anomalies(readings, radius, threshold):