import sys, numpy as np, matplotlib.pyplot as plt
sys.path.insert(0,'..')
from engine import ch15
from dataclasses import replaceMFAA Chapter 15 Laboratory
Volterra and Signature Engines (book §15.8)
A Volterra simulator (fractional kernels, exponential-sum lifts) and a signature extractor (Chen’s identity, Lévy area), with the identification confound as the centerpiece. Seed 20261500.
1. Roughness: increment-variance scaling recovers 2H
Fractional Brownian motion by exact circulant embedding.
for H in (0.1, 0.3, 0.5):
sc = ch15.increment_variance_scaling(ch15.VolterraParams(H=H))
print(f"H={H}: fitted slope {sc['fitted_slope']:.3f} (target 2H={2*H:.1f})")H=0.1: fitted slope 0.205 (target 2H=0.2)
H=0.3: fitted slope 0.612 (target 2H=0.6)
H=0.5: fitted slope 1.005 (target 2H=1.0)
2. The Gaussian-Markov criterion
R(s,u)R(t,t) = R(s,t)R(t,u) holds for exponential kernels, fails for fractional.
gm = ch15.gaussian_markov_residual(0.3)
print(f"fractional residual (nonzero => non-Markov): {gm['fractional_residual']:.4f}")
print(f"exponential residual (zero => Markov): {gm['exponential_residual']:.2e}")fractional residual (nonzero => non-Markov): 0.0258
exponential residual (zero => Markov): -1.11e-16
3. Exponential-sum lift and Chen’s identity
for n in (2, 5, 8):
e = ch15.exponential_sum_lift(ch15.VolterraParams(), n_exp=n)
print(f"n_exp={n}: relative kernel error {e['rel_error']:.4f}")
chen = ch15.chen_identity_check()
print(f"\nChen's identity: level-1 error {chen['level1_error']:.2e}, level-2 error {chen['level2_error']:.2e}")n_exp=2: relative kernel error 0.4278
n_exp=5: relative kernel error 0.0152
n_exp=8: relative kernel error 0.0006
Chen's identity: level-1 error 0.00e+00, level-2 error 7.11e-15
4. Validation checks
v = ch15.validation_checks()
for k,d in v.items():
if isinstance(d,dict): print(k, 'PASS' if d['pass_'] else 'FAIL')
print('ALL:', v['all_pass'])V1_roughness_slope PASS
V2_gaussian_markov PASS
V3_lift_convergence PASS
V4_chen_identity PASS
V5_smoothing_memory PASS
V6_reproducible PASS
ALL: True