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 → round to integers. The app shows the filter (convolution
7kernel and frequency response, with cutoffs in Hz against a chosen sample
8rate), a window of the generated integer signal (stationary by default, with a
9play toggle to let it stream endlessly), and the measured compression of a
10block of the generated integers under nine methods — zlib, zstd, and an rANS
11entropy coder, each raw, delta-coded, and LPC-residual-coded — as bits per
12sample and as ratio against raw int16 storage. The predictor order and the
13block size are controls, so the measurement can be pushed from 10k to a million
14samples and LPC from order 1 to 128. Each prefilter group also carries a hollow
15bar: the order-0 entropy of the stream being coded, the limit a per-sample
16entropy coder cannot beat, which ANS misses by 1–2% (its symbol table plus its
17own arithmetic loss).
19The entropy rate R of the process — the bits/sample limit no lossless method
20can beat — is estimated in the browser by the method of the companion
21[timeseries-entropy](https://github.com/concept-collection/timeseries-entropy)
22package: an unbiased Monte-Carlo estimator of H(z_next | a long past), by Gibbs
23sampling the latent Gaussian under the rounding constraints and applying
24Rhee–Glynn randomized telescoping to the sampled chain. A button starts a web
25worker that averages one independent past at a time (live mean ± se, dashed
26line on the chart) until stopped; the app also shows the exact command to run
27the Python original at the same settings as an independent check. The
28in-browser code in `src/entropy/` is a hand-synced TypeScript port of that
29package — change one, change the other. A WebGPU Gibbs sweep may replace the
30scalar one someday; the sweep is isolated so it can be swapped.
32## Run it
34```sh
35npm install
36npm run dev
37```
39## Layout
41```
42src/model/ the latent source (fixed seeded randomness indexed by sample
43 position, convolved zero-phase with the kernel on demand)
44 and the FIR presets
45src/entropy/ the unbiased entropy-rate estimator: hand-synced TypeScript
46 port of the timeseries-entropy package (Gibbs conditional
47 sampler, Rhee–Glynn telescoping, Cody erfc / Acklam ndtri,
48 xoshiro128** RNG)
49src/compress/ lossless codecs run in the browser: zlib (fflate), zstd (wasm),
50 ans.ts (a bit-identical port of simple_ans), and FLAC-style
51 integer LPC; borrowed from entropy-quantized-linear-transform
52src/worker/ the codecs and the estimator run off the main thread; the
53 estimator worker refines one past at a time until terminated
54src/components/ controls, filter plots, signal canvas, compression chart,
55 and the entropy-rate method note
56```
58Every reported size round-trips through the decoder and includes whatever the
59decoder needs (ANS symbol table, LPC coefficients). The signal view and the
60compression block read the same fixed latent noise sequence — parameter changes
61transform the same underlying data rather than resampling it, and the first
62window shown is the start of the block that gets compressed.