Hands-On
3. Let's Get Practical
Enough talk, let's get our hands dirty with a real-world example! We'll use the simplest smoothing technique — the moving average — to see how it works in practice. Imagine we have a series of daily temperatures for a week: 20, 22, 25, 23, 21, 19, 24 (in degrees Celsius). We want to smooth this data to see the general trend without being distracted by daily fluctuations.
Let's choose a window size of 3. This means that for each day, we'll average the temperature of that day and the two surrounding days. So, for the third day (temperature 25), we'll calculate the average of the second, third, and fourth days: (22 + 25 + 23) / 3 = 23.33. We repeat this process for each day, sliding the window along the data.
Here's the smoothed data we get: For day 1, we can't apply the full window of 3, so we may leave it out or use a window of 2: (20 + 22) / 2 = 21. Day 2: (20 + 22 + 25) / 3 = 22.33. Day 3: (22 + 25 + 23) / 3 = 23.33. Day 4: (25 + 23 + 21) / 3 = 23. Day 5: (23 + 21 + 19) / 3 = 21. Day 6: (21 + 19 + 24) / 3 = 21.33. Day 7: Again we may use a window of 2: (19 + 24) / 2 = 21.5.
Notice how the smoothed temperatures are less volatile than the original temperatures. The moving average has effectively dampened the daily fluctuations, giving us a clearer picture of the overall temperature trend. Of course, the choice of window size is crucial. A smaller window will preserve more detail but won't smooth as much, while a larger window will smooth more but may blur important features.