Time Series • Time Series Analysis and Components
Time Series / P2.06 Central Tendency and Dispersion

P2.06 Central Tendency and Dispersion

Practical 2 Time Series Analysis and Components

Compare mean vs median and standard deviation vs IQR on a series that contains one spike.

Practical / Solution

P2.06 Central Tendency and Dispersion

Problem Statement

Compare mean vs median and standard deviation vs IQR on a series that contains one spike.

Learning Outcomes

  • See that the mean is pulled by a spike.
  • See that the median and IQR are more resistant.

Theory

Mean and standard deviation use all values and are sensitive to outliers. Median and IQR are more robust. Time series often contain irregular shocks.

Dataset / Data Source

Teaching series: 10, 11, 12, 12, 13, 40, 14, 15.

Analysis / Program

import pandas as pd s = pd.Series([10, 11, 12, 12, 13, 40, 14, 15]) print("Mean:", s.mean(), "Median:", s.median()) print("Std:", round(s.std(), 2), "IQR:", s.quantile(0.75) - s.quantile(0.25))

Expected Output

Mean larger than median; std larger relative to IQR because of the 40 spike.

Result / Interpretation

The spike is an irregular observation. Using only the mean would overstate the typical level. Students should inspect the plot before trusting a mean forecast.

Note

Irregular shocks inflate the mean and the standard deviation.