-
Book Overview & Buying
-
Table Of Contents
Python Data Analysis - Fourth Edition
By :
In the previous section, we already touched on a few things about statistical models, such as the MA, but we will discuss time-series statistical models in much more detail in this section.
As we already mentioned regarding the MA methodology, there are a few other methods for smoothing that you need to know. We have already learned about the simple MA method, but other versions cater more to the time information: the Weighted Moving Average (WMA).
The WMA equation can be calculated as follows:
The calculation is similar to the SMA, but we add the parameter w, which represents the weight for the current time value. We can assign weights according to business needs or in descending order, giving more weight to values from more recent times.
If we perform the WMA with Python, it will be as follows:
# Weighted Moving Average
import numpy as np
weights = np.arange(1, 8)
filtered_sales['WMA_7_Revenue'] = filtered_sales[&apos...