Implemented anomaly detection with automatic threshold selection.