Given a stream of incoming events, how would you design an algorithm to detect anomalies in real-time?