/ proof-of-concept / timeseries-compressibility
Sign in
proof-of-concept / timeseries-compressibility
timeseries-compressibility / README.md
57 lines · 2.6 KBPreviewCodeBlameHistoryRaw
1# timeseries-compressibility
3Interactive exploration of how compressible quantized time series are.
5The generating model is: i.i.d. Gaussian noise (std σ, measured in quantization
6steps) → FIR filter → optional additive uniform dither on [-½, ½) → round to
7integers. The app shows the filter (convolution kernel and frequency response,
8with cutoffs in Hz against a chosen sample rate), a window of the generated
9integer signal (stationary by default, with a play toggle to let it stream
10endlessly), and the measured compression of a 120,000-sample
11block under nine methods — zlib, zstd, and an rANS entropy coder, each raw,
12delta-coded, and LPC-residual-coded — as bits per sample and as ratio against
13raw int16 storage.
15Alongside the measurements it plots a theoretical bits/sample R: quantization
16is modeled as an additive white noise floor on the spectrum, the one-step
17Wiener prediction error of the resulting process comes from the
18Szegő–Kolmogorov formula, and R is the exact entropy of that innovation
19quantized at unit step:
21```
22S_z(f) = σ²|H(f)|² + σ_q² σ_q² = 1/12 (1/6 with dither)
23σ_e² = exp( 2 ∫₀^½ ln S_z(f) df )
24R = H_Δ(σ_e) (exact quantized-Gaussian entropy)
25```
27Where the spectrum sits well above one step² this reduces to the classical
28Gaussian entropy rate ½log₂(2πe) + ∫log₂S df; the noise floor keeps it finite
29and positive where a deep stopband would send that integral to −∞. LPC + ANS
30should approach R; probing where the approximation holds is the point. The
31math section is a stub for the full derivation.
33## Run it
35```sh
36npm install
37npm run dev
38```
40## Layout
42```
43src/model/ the latent source (fixed seeded randomness indexed by sample
44 position, convolved zero-phase with the kernel on demand),
45 FIR presets, and the theoretical-rate formula
46src/compress/ lossless codecs run in the browser: zlib (fflate), zstd (wasm),
47 ans.ts (a bit-identical port of simple_ans), and FLAC-style
48 integer LPC; borrowed from entropy-quantized-linear-transform
49src/worker/ the codecs run off the main thread on a debounced parameter set
50src/components/ controls, filter plots, signal canvas, compression chart
51```
53Every reported size round-trips through the decoder and includes whatever the
54decoder needs (ANS symbol table, LPC coefficients). The signal view and the
55compression block read the same fixed latent noise sequence — parameter changes
56transform the same underlying data rather than resampling it, and the first
57window shown is the start of the block that gets compressed.
↑↓ move↵openescclose