This notebook reviews the statistical foundations of forecasting: probability distributions, maximum likelihood estimation, and hypothesis testing — with emphasis on their role in time-series modelling.
import matplotlib as mplimport matplotlib.pyplot as pltimport numpy as np# Edinburgh paletteUOE_RED ='#7A2318'UOE_GOLD ='#B8860B'UOE_BLUE ='#2a78d6'UOE_GREY ='#52514e'COLOURS = [UOE_RED, UOE_BLUE, UOE_GOLD, '#2ca02c', '#9467bd', '#e377c2']mpl.rcParams.update({'figure.figsize': (10, 5),'axes.prop_cycle': mpl.cycler(color=COLOURS),'axes.spines.top': False, 'axes.spines.right': False,'axes.labelsize': 12, 'axes.titlesize': 14,'font.size': 11, 'legend.fontsize': 10,'lines.linewidth': 2,})print("Plotting style set ✓")
Plotting style set ✓
2.1 Key Distributions in Forecasting
Three distributions appear constantly:
Normal — the workhorse; errors in most linear models
Student-\(t\) — heavier tails; robust to outliers
Laplace — even heavier tails; connection to \(L_1\) estimation
from scipy.stats import norm, t as student_t, laplacex = np.linspace(-5, 5, 500)fig, ax = plt.subplots(figsize=(10, 5))ax.plot(x, norm.pdf(x), label='Normal(0,1)', color=UOE_BLUE)ax.plot(x, student_t.pdf(x, df=3), '--', label='Student-$t$ (df=3)', color=UOE_RED)ax.plot(x, laplace.pdf(x), ':', label='Laplace(0,1)', color=UOE_GOLD, lw=2.5)ax.fill_between(x, norm.pdf(x), alpha=0.1, color=UOE_BLUE)ax.set_xlabel('$x$')ax.set_ylabel('$f(x)$')ax.set_title('Comparison of Probability Density Functions')ax.legend()plt.tight_layout()plt.show()
2.2 Effect of Outliers on Distribution Fitting
When data contains outliers, the Normal distribution shifts its mean and inflates its variance to accommodate them. The Student-\(t\) distribution is more robust.
For a linear model \(y_t = x_t'\beta + \varepsilon_t\) with \(\varepsilon_t \sim N(0, \sigma^2)\), maximising the log-likelihood is equivalent to minimising the sum of squared residuals.