Solution: Quadratic Variation by Simulation
Exercise: Quadratic Variation by Simulation
Part 1 — Single-path quadratic variation
# Python
import numpy as np
rng = np.random.default_rng(42)
def simulate_path(n, T=1.0):
dt = T / n
dW = rng.normal(0, np.sqrt(dt), size=n)
return dW
for n in [10, 100, 1000, 10000]:
dW = simulate_path(n)
Q_n = np.sum(dW ** 2)
print(f"n = {n:5d} Q_n = {Q_n:.4f}")
# n = 10 Q_n = 0.8761
# n = 100 Q_n = 0.9635
# n = 1000 Q_n = 0.9975
# n = 10000 Q_n = 0.9942hovers around already at and is within a fraction of a percent at . The convergence is clear and fast.
Part 2 — First-order variation
# Python
rng = np.random.default_rng(42)
for n in [10, 100, 1000, 10000]:
dW = simulate_path(n)
V_n = np.sum(np.abs(dW))
print(f"n = {n:5d} V_n = {V_n:.4f}")
# n = 10 V_n = 2.4067
# n = 100 V_n = 7.9212
# n = 1000 V_n = 25.2168
# n = 10000 V_n = 79.7416grows roughly as : going from to (a factor of 100) increases by a factor of about 10. This is consistent with the theoretical result
(using for ), which diverges as . Total variation is infinite in the refinement limit — this is the rigorous fact behind the claim that is not of bounded variation.
Part 3 — Empirical distribution of
# Python
rng = np.random.default_rng(0)
N = 1000
n = 1000
T = 1.0
Q_samples = np.empty(N)
for k in range(N):
dW = rng.normal(0, np.sqrt(T / n), size=n)
Q_samples[k] = np.sum(dW ** 2)
mean_Q = Q_samples.mean()
std_Q = Q_samples.std(ddof=1)
theoretical_std = np.sqrt(2 * T**2 / n)
print(f"Empirical mean(Q_n) = {mean_Q:.4f} (theoretical 1.0000)")
print(f"Empirical std(Q_n) = {std_Q:.4f} (theoretical {theoretical_std:.4f})")
# Empirical mean(Q_n) = 1.0012 (theoretical 1.0000)
# Empirical std(Q_n) = 0.0446 (theoretical 0.0447)The mean is indistinguishable from and the standard deviation matches to three decimal places. At finite , is a random quantity — it fluctuates around with spread . The convergence in is exactly the statement that this spread vanishes as .
Part 4 — Why both statements are consistent
The two sums behave differently because of how they weight increments of typical size . Each , so:
- First-order variation: .
- Quadratic variation: (finite).
The squaring converts a term of size into one of size , which when summed times yields exactly . The absolute value does not, so the sum of absolute increments blows up. This is the defining signature of a rough path: infinite variation at first order, finite variation at order 2.
Takeaways
- Quadratic variation converges to fast. At the relative error is already sub-percent — this is why "" is such a useful calculus rule in practice.
- First-order variation diverges. This is the rigorous reason the Itô integral cannot be defined pathwise as a Riemann-Stieltjes integral — has no finite variation to integrate against.
- is random for finite and deterministic in the limit. The standard deviation is a useful diagnostic: when simulating a discretised SDE, the pathwise "energy" should be close to , and its fluctuation quantifies your time-step resolution.
- This exercise is the numerical foundation of Itô's lemma. The correction in Itô's lemma is there because , not zero.