tezvyn:

Moving Average: Smoothing Out the Noise in Data

AI-drafted, machine-checkedSource: Wikipedia: Moving averagebeginner
Moving Average: Smoothing Out the Noise in Data

A moving average smooths out noisy data by replacing each point with the average of its neighbors, revealing the underlying trend. It's used to track stock prices or server metrics without overreacting to short spikes.

THE MENTAL MODEL: A moving average acts like a filter for noisy data, smoothing out short-term fluctuations to reveal the underlying trend. Imagine squinting to see the general shape of a jagged line; the moving average is the mathematical equivalent of that action, turning volatile data into a smoother, more interpretable signal.

HOW IT WORKS: The most common type is the Simple Moving Average (SMA). To calculate an N-day SMA, you take the data points for the last N days, sum them up, and divide by N. Then you slide the window forward one day and repeat. For example, with daily temperatures [70, 75, 72, 68, 71] and a 3-day window, the first average is (70+75+72)/3 = 72.3. The next is (75+72+68)/3 = 71.7. This creates a new, smoother time series. Other forms exist, like a weighted moving average that gives more importance to recent data, or a cumulative average that includes all data up to the current point.

WHEN TO USE IT: Use a moving average when you need to understand the long-term trend in volatile time-series data. It's ideal for financial charts to see if a stock is trending up or down over months, for monitoring systems to track average CPU load without getting alerted by brief spikes, or for analyzing weekly sales figures to see seasonal patterns.

WHEN NOT TO USE IT: Avoid moving averages when individual data points are critical. For example, in fraud detection, a single anomalous transaction is important and should not be averaged away. It also introduces lag; the average always trails the most recent data. Therefore, it's unsuitable for systems that require instantaneous, real-time responses to every data point.

ONE CANONICAL EXAMPLE: In stock market analysis, traders use the 50-day and 200-day moving averages as key indicators. When the shorter-term 50-day average crosses above the longer-term 200-day average (a "golden cross"), it's often interpreted as a bullish signal for a long-term upward trend. The opposite is a "death cross."

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.