Skip to main content

Module delay_embed

Module delay_embed 

Source
Expand description

Takens Delay Embedding and Correlation Dimension estimator.

Takens’ theorem (1981): if a time series is generated by a deterministic dynamical system with attractor dimension d, then 2d+1 delay-embedded observations faithfully reconstruct the attractor — regardless of total sequence length.

Applied to KV caches: the minimum number of KV vectors needed for lossless attention reconstruction is bounded by 2d+1, where d is the correlation dimension of the KV sequence treated as a dynamical trajectory.

§Workflow

  1. Collect a KV sequence as rows of a matrix.
  2. Embed with delay_embedding(series, tau, embed_dim).
  3. Estimate d with correlation_dimension(points, ...).
  4. Compute minimum cache size: min_cache_size_takens(d).

Functions§

correlation_dimension
Estimate the correlation dimension of a point cloud using the Grassberger–Procaccia algorithm (1983).
delay_embedding
Build a delay-embedded point cloud from a scalar or vector time series.
min_cache_size_takens
Minimum number of KV vectors needed to reconstruct the attractor, per Takens’ theorem: 2 * ceil(d) + 1.