# Anomaly Detection in Time Series Using Statistical Analysis

DevFeed: [Anomaly Detection in Time Series Using Statistical Analysis](<https://devfeed.tech/articles/anomaly-detection-in-time-series-using-statistical-analysis-23719.md>)

Original publisher: [Read original article](<https://medium.com/booking-com-development/anomaly-detection-in-time-series-using-statistical-analysis-cc587b21d008?source=rss----1c36c35f9c76---4>)

Author: Ivan Shubin

Published: 2025-04-15T18:45:36Z

Content type: tutorial

Language: en

Sources: [Booking.com Development - Medium](<https://devfeed.tech/sources/booking-com-development-medium.md>)

Topics: [Time Series](<https://devfeed.tech/topics/time-series.md>), [Statistics](<https://devfeed.tech/topics/statistics.md>), [Monitoring](<https://devfeed.tech/topics/monitoring.md>), [data](<https://devfeed.tech/topics/data.md>), [Website](<https://devfeed.tech/topics/website.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [anomaly-detection](<https://devfeed.tech/tags/anomaly-detection.md>), [article](<https://devfeed.tech/tags/article.md>), [behavior](<https://devfeed.tech/tags/behavior.md>), [data](<https://devfeed.tech/tags/data.md>), [grafana](<https://devfeed.tech/tags/grafana.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [monitoring](<https://devfeed.tech/tags/monitoring.md>), [outlier-detection](<https://devfeed.tech/tags/outlier-detection.md>), [sre](<https://devfeed.tech/tags/sre.md>), [statistics](<https://devfeed.tech/tags/statistics.md>), [time-series](<https://devfeed.tech/tags/time-series.md>), [web](<https://devfeed.tech/tags/web.md>)

## AI overview

This article explains how to build a statistical anomaly detection system for time series data. It describes why static thresholds and comparisons with the same point one week earlier can miss recurring or gradual problems, and introduces standard deviation as a foundational statistical measure.

## Source excerpt

Setting up alerts for metrics isn't always straightforward. In some cases, a simple threshold works just fine -- for example, monitoring disk space on a device. You can just set an alert at 10% remaining, and you're covered. The same goes for tracking available memory on a server. But what if we need to monitor something like user behavior on a website? Imagine running a web store where you sell products. One approach might be to set a minimum threshold for daily sales and check it once a day. But what if something goes wrong, and you need to catch the issue much sooner -- within hours or even minutes? In that case, a static threshold won't cut it because user activity fluctuates throughout the day. This is where anomaly detection comes in. What exactly is anomaly detection? Instead of relying on simple rules, it involves analyzing historical data to spot unusual patterns. There are various ways to implement anomaly detection, including machine learning and statistical analysis. In this article, we'll focus on the statistical approach and walk through how we built our own anomaly detection system for time series data from scratch at Booking. The Naïve Approach One common mistake I've seen across different companies and teams is trying to detect anomalies by simply comparing a business metric to its value exactly one week ago. This week vs previous week At first glance, this approach isn't entirely useless -- you can catch some anomalies, as shown in the image above. But is it a reliable long-term solution? Not really. The big flaw is that today's anomaly becomes next week's baseline. That means if the same issue occurs again at the same time next week, it may go completely unnoticed because we're now comparing against a flawed reference point. Outage in previous week That doesn't look right, our simplistic approach doesn't know that last week's data was compromised. Another limitation of this method is that it only considers a single week at a time. But what if perform