Code
import matplotlib.pyplot as plt
rng = np.random.default_rng(151)
n_values = np.array([1, 2, 5, 10, 20, 50, 100, 200, 500])
repetitions = 20_000
sigma_sq = np.var(np.arange(1, 7)) # variance of a single fair die roll
empirical_var = []
for n in n_values:
sample_means = rng.integers(1, 7, size=(repetitions, n)).mean(axis=1)
empirical_var.append(sample_means.var())
empirical_var = np.array(empirical_var)
fig, ax = plt.subplots(figsize=(5.5, 3.5))
ax.loglog(n_values, empirical_var, 'o', label=r'empirical $\mathrm{Var}(\bar X_n)$')
ax.loglog(n_values, sigma_sq / n_values, '--', label=r'$\sigma^2/n$')
ax.set_xlabel('$n$')
ax.set_ylabel('variance')
ax.legend()
plt.tight_layout()
plt.show()