Analysis Math Formulas

Moving Average (MA)

$$ \text{Moving Average (MA)} = \frac{\sum_{i=0}^{n-1} x_{t-i}}{n} $$
Variables:
$x_{t-i}$ -- data point at time period $t-i$
$n$ -- number of periods in the moving average

The moving average smooths out short-term fluctuations and highlights longer-term trends in data. It is commonly used in sales forecasting to identify trends over a specified number of periods.

  • Shorter MA (smaller n) → more responsive to recent changes, but more volatile
  • Longer MA (larger n) → smoother, but slower to react to changes
Example:

If a product has weekly sales data: [150, 200, 250, 300, 350] and using a 3-week moving average: Interpretation: the 3-week moving average for week 5 is 300 units.

\[\text{Moving Average (MA)} = \frac{250 + 300 + 350}{3} = \frac{900}{3} = 300\]

Weighted Moving Average (WMA)

$$ \text{Weighted Moving Average} = \sum_{i=0}^{n-1} w_i \cdot x_{t-i} $$
Variables:
$x_{t-i}$ -- data point at time period $t-i$
$w_i$ -- weight for data point at time period $t-i$ (where $\sum w_i = 1$)
$n$ -- number of periods in the weighted moving average

The weighted moving average assigns different weights to data points, typically giving more importance to recent observations. This allows the average to be more responsive to recent changes while still smoothing out fluctuations.

  • Higher weights for recent data → more responsive to recent trends
  • Weights should sum to 1 or be normalized
Example:

If a product has weekly sales data: [150, 200, 250, 300, 350] and using weights [0.5, 0.3, 0.2] for a 3-week weighted moving average: Interpretation: the weighted moving average for week 5 is 305 units.

\[\text{Weighted Moving Average (WMA)} = \frac{0.5 \cdot 350 + 0.3 \cdot 300 + 0.2 \cdot 250}{0.5 + 0.3 + 0.2} = \frac{175 + 90 + 50}{1.0} = 315\]

Exponential Moving Average (EMA)

$$ \text{EMA}_t = \alpha \cdot x_t + (1 - \alpha) \cdot \text{EMA}_{t-1} $$
Variables:
$x_t$ -- data point at time period $t$
$\text{EMA}_{t-1}$ -- EMA value at time period $t-1$
$\alpha$ -- smoothing factor (0 < $\alpha$ ≤ 1)

The exponential moving average gives more weight to recent data points, making it more responsive to recent changes. The smoothing factor $\alpha$ determines the rate at which older data points’ influence decreases.

  • Higher $\alpha$ → more responsive to recent changes
  • Lower $\alpha$ → smoother, less responsive
Example:

If a product has weekly sales data: [150, 200, 250, 300, 350] and using a smoothing factor $\alpha$=0.5: Interpretation: the EMA for week 5 is 325 units.

\[\text{EMA}_1 = 150 \\ \text{EMA}_2 = 0.5 \cdot 200 + 0.5 \cdot 150 = 175 \\ \text{EMA}_3 = 0.5 \cdot 250 + 0.5 \cdot 175 = 212.5 \\ \text{EMA}_4 = 0.5 \cdot 300 + 0.5 \cdot 212.5 = 256.25 \\ \text{EMA}_5 = 0.5 \cdot 350 + 0.5 \cdot 256.25 = 303.125\]

Coefficient of Variation (CV)

$$ \text{Coefficient of Variation (CV)} = \frac{\sigma}{\mu} \times 100 $$
Variables:
$\sigma$ -- standard deviation of the data
$\mu$ -- mean of the data

The coefficient of variation measures the relative variability of a dataset. It expresses the standard deviation as a proportion of the mean, allowing you to compare variability across products, periods, or units that may have different scales.

  • High CV → more variability relative to the mean
  • Low CV → more stable, predictable data
Example:

If a product has average weekly sales $\mu$=200 units, with standard deviation $\sigma$=50 units: Interpretation: weekly sales vary by 25% relative to the mean.

\[\text{Coefficient of Variation (CV)} = \frac{50}{200} \times 100 = .25\]

Range to Mean Ratio (Range/Mean)

$$ \text{Range to Mean Ratio} = \frac{\text{Max} - \text{Min}}{\mu} $$
Variables:
$\text{Max}$ -- maximum value in the dataset
$\text{Min}$ -- minimum value in the dataset
$\mu$ -- mean of the data

The range to mean ratio provides a simple measure of variability by comparing the spread of the data (range) to its average level (mean).

  • High ratio → wide range relative to mean, indicating more variability
  • Low ratio → narrow range relative to mean, indicating more stability
Example:

If a product has average weekly sales $\mu$=200 units, with max sales=300 units and min sales=100 units: Interpretation: weekly sales vary by 1.0 times the mean.

\[\text{Range to Mean Ratio} = \frac{300 - 100}{200} = \frac{200}{200} = 1.0\]

Mean Absolute Deviation (MAD)

$$ \text{Mean Absolute Deviation (MAD)} = \frac{\sum |x_i - \mu|}{n} $$
Variables:
$x_i$ -- each individual data point
$\mu$ -- mean of the data
$n$ -- number of data points

The mean absolute deviation measures the average distance between each data point and the mean. It provides a straightforward measure of variability that is less sensitive to extreme values than standard deviation.

  • High MAD → more variability
  • Low MAD → more stability
Example:

If a product has weekly sales data: [150, 200, 250, 300, 350] with mean $\mu$=250: Interpretation: on average, weekly sales deviate from the mean by 70 units.

\[\text{Mean Absolute Deviation (MAD)} = \frac{|150-250| + |200-250| + |250-250| + |300-250| + |350-250|}{5} = \frac{100 + 50 + 0 + 50 + 100}{5} = \frac{300}{5} = 60\]

Mean Absolute Percentage Error (MAPE)

$$ \text{Mean Absolute Percentage Error (MAPE)} = \frac{1}{n} \sum \left| \frac{A_i - F_i}{A_i} \right| \times 100\% $$
Variables:
$A_i$ -- actual value
$F_i$ -- forecasted value
$n$ -- number of data points

MAPE measures the average percentage error between actual and forecasted values. It provides insight into the accuracy of forecasts relative to the size of the actual values.

Example:

If actual sales are [100, 200, 300] and forecasted sales are [110, 190, 310]: Interpretation: on average, forecast errors are about 6.67% of actual sales.

\[\text{Mean Absolute Percentage Error (MAPE)} = \frac{\left| \frac{100-110}{100} \right| + \left| \frac{200-190}{200} \right| + \left| \frac{300-310}{300} \right|}{3} \times 100\% = \frac{0.10 + 0.05 + 0.0333}{3} \times 100\% \approx 6.67\%\]

Root Mean Square Error (RMSE)

$$ \text{Root Mean Square Error (RMSE)} = \sqrt{\frac{1}{n} \sum (A_i - F_i)^2} $$
Variables:
$A_i$ -- actual value
$F_i$ -- forecasted value
$n$ -- number of data points

RMSE measures the average magnitude of forecast errors, giving more weight to larger errors due to squaring. It provides insight into the accuracy of forecasts in the same units as the data.

  • Lower RMSE → better forecast accuracy
  • Higher RMSE → larger forecast errors
Example:

If actual sales are [100, 200, 300] and forecasted sales are [110, 190, 310]: Interpretation: on average, forecast errors are about 10.0 units.

\[\text{Root Mean Square Error (RMSE)} = \sqrt{\frac{(100-110)^2 + (200-190)^2 + (300-310)^2}{3}} = \sqrt{\frac{100 + 100 + 100}{3}} = \sqrt{100} = 10.0\]

Forecast Bias

$$ \text{Forecast Bias} = \frac{1}{n} \sum (F_i - A_i) $$
Variables:
$A_i$ -- actual value
$F_i$ -- forecasted value
$n$ -- number of data points

Forecast bias measures the average difference between forecasted and actual values. It indicates whether forecasts tend to overestimate (positive bias) or underestimate (negative bias) actual outcomes.

  • Positive bias → forecasts are generally too high
  • Negative bias → forecasts are generally too low
  • Zero bias → forecasts are unbiased on average
Example:

If actual sales are [100, 200, 300] and forecasted sales are [110, 190, 310]: Interpretation: on average, forecasts are 3.33 units higher than actual sales.

\[\text{Forecast Bias} = \frac{(110-100) + (190-200) + (310-300)}{3} = \frac{10 - 10 + 10}{3} = \frac{10}{3} \approx 3.33\]

Forecast Bias Significance

$$ \text{Forecast Bias Significance} = \frac{\text{Forecast Bias}}{\text{RMSE}} \times 100\% $$
Variables:
$\text{Forecast Bias}$ -- average forecast bias
$\text{RMSE}$ -- root mean square error

This metric assesses the significance of forecast bias relative to overall forecast accuracy (RMSE). It helps determine if the bias is substantial compared to the typical size of forecast errors.

  • High positive value → significant over-forecasting
  • High negative value → significant under-forecasting
  • Value near zero → bias is small relative to forecast errors
Example:

If forecast bias is 3.33 units and RMSE is 10.0 units: Interpretation: forecast bias is about 33.3% of the typical forecast error.

\[\text{Forecast Bias Significance} = \frac{3.33}{10.0} \times 100\% \approx 33.3\%\]

Forecast Bias Confidence Interval

$$ \text{Confidence Interval} = \bar{x} \pm z \left( \frac{\sigma}{\sqrt{n}} \right) $$
Variables:
$\bar{x}$ -- forecast bias (mean of forecast errors)
$z$ -- Z-score for desired confidence level (e.g., 1.96 for 95% confidence)
$\sigma$ -- RMSE (standard deviation of forecast errors)
$n$ -- number of data points

This formula calculates the confidence interval for forecast bias, providing a range within which the true bias is likely to fall with a specified level of confidence. It accounts for the variability in forecast errors (RMSE) and the sample size (n).

Example:

If forecast bias is 3.33 units, RMSE is 10.0 units, n=3, and using Z=1.96 for 95% confidence: Interpretation: we are 95% confident the true forecast bias lies between -8.09 and 14.75 units.

\(\text{Forecast Bias Confidence Interval} = 3.33 \pm 1.96 \times \frac{10.0}{\sqrt{3}} \approx 3.33 \pm 11.42\) \(\text{Interval} \approx [-8.09, 14.75]\)