Anomaly detection for data aggregation in wireless sensor networks