/ concept-collection / timeseries-compressibility
Sign in
concept-collection / timeseries-compressibility
timeseries-compressibility / README.md
78 lines · 4.3 KBCodeBlameHistory
3Interactive exploration of how compressible quantized time series are.
5The generating model is: i.i.d. Gaussian noise (std σ, measured in quantization
43704d2Clear the analytic rate: R now comes from the timeseries-entropy estimatorJeremy Magland 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
4ec0133Code against the prediction, not the integer residualJeremy Magland 10block of the generated integers under ten methods — zlib, zstd, and an rANS
11entropy coder, each raw, delta-coded, and LPC-residual-coded, plus the
12conditional-Gaussian coder below — as bits per sample and as ratio against raw
13int16 storage. The predictor order and the
43704d2Clear the analytic rate: R now comes from the timeseries-entropy estimatorJeremy Magland 14block size are controls, so the measurement can be pushed from 10k to a million
4ec0133Code against the prediction, not the integer residualJeremy Magland 15samples and LPC from order 1 to 128. Under the chart, every coder that codes
16against an explicit model is scored against it — ANS against the order-0
17entropy of the stream it was handed, the arithmetic coder against its own
18predictive distribution — which separates how well a coder does its job (1–2%
19overhead for ANS, its symbol table plus its arithmetic loss) from how good the
20model was in the first place.
22The tenth method is the one that can pass those hollow bars: the same LPC
23prediction kept at full precision, each sample arithmetic-coded under a
24discretized Gaussian centred on the real-valued prediction. When the
25prediction error is a fraction of a quantization step (narrowband filters,
26moderate σ), whether the prediction falls near a bin centre or a bin edge is
27worth ~0.3–0.4 bits/sample — information the integer residual has already
28destroyed, which is why LPC+ANS plateaus far above R there. Its only limit is
29R itself. Like every other bar, its size is real: encoded, decoded, verified,
30side information included.
6b485dfCall R the entropy rate, and put the estimate button under its readoutJeremy Magland 32The entropy rate R of the process — the bits/sample limit no lossless method
33can beat — is estimated in the browser by the method of the companion
43704d2Clear the analytic rate: R now comes from the timeseries-entropy estimatorJeremy Magland 34[timeseries-entropy](https://github.com/concept-collection/timeseries-entropy)
35package: an unbiased Monte-Carlo estimator of H(z_next | a long past), by Gibbs
36sampling the latent Gaussian under the rounding constraints and applying
3f857e3Estimate the reference rate R in the browserJeremy Magland 37Rhee–Glynn randomized telescoping to the sampled chain. A button starts a web
38worker that averages one independent past at a time (live mean ± se, dashed
39line on the chart) until stopped; the app also shows the exact command to run
40the Python original at the same settings as an independent check. The
41in-browser code in `src/entropy/` is a hand-synced TypeScript port of that
42package — change one, change the other. A WebGPU Gibbs sweep may replace the
43scalar one someday; the sweep is isolated so it can be swapped.
45## Run it
47```sh
48npm install
49npm run dev
50```
52## Layout
54```
5bab85aRatio-first chart, quantization-floor theory formula, line-segment view, fixed latent dataJeremy Magland 55src/model/ the latent source (fixed seeded randomness indexed by sample
43704d2Clear the analytic rate: R now comes from the timeseries-entropy estimatorJeremy Magland 56 position, convolved zero-phase with the kernel on demand)
57 and the FIR presets
6b485dfCall R the entropy rate, and put the estimate button under its readoutJeremy Magland 58src/entropy/ the unbiased entropy-rate estimator: hand-synced TypeScript
3f857e3Estimate the reference rate R in the browserJeremy Magland 59 port of the timeseries-entropy package (Gibbs conditional
60 sampler, Rhee–Glynn telescoping, Cody erfc / Acklam ndtri,
61 xoshiro128** RNG)
36e8ceaInteractive explorer for compressibility of quantized filtered Gaussian time seriesJeremy Magland 62src/compress/ lossless codecs run in the browser: zlib (fflate), zstd (wasm),
4ec0133Code against the prediction, not the integer residualJeremy Magland 63 ans.ts (a bit-identical port of simple_ans), FLAC-style
64 integer LPC (borrowed from entropy-quantized-linear-transform),
65 and conditionalGaussian.ts — real-coefficient prediction with
66 each sample arithmetic-coded under a discretized Gaussian at
67 the real-valued prediction
3f857e3Estimate the reference rate R in the browserJeremy Magland 68src/worker/ the codecs and the estimator run off the main thread; the
69 estimator worker refines one past at a time until terminated
43704d2Clear the analytic rate: R now comes from the timeseries-entropy estimatorJeremy Magland 70src/components/ controls, filter plots, signal canvas, compression chart,
6b485dfCall R the entropy rate, and put the estimate button under its readoutJeremy Magland 71 and the entropy-rate method note
74Every reported size round-trips through the decoder and includes whatever the
5bab85aRatio-first chart, quantization-floor theory formula, line-segment view, fixed latent dataJeremy Magland 75decoder needs (ANS symbol table, LPC coefficients). The signal view and the
76compression block read the same fixed latent noise sequence — parameter changes
77transform the same underlying data rather than resampling it, and the first
78window shown is the start of the block that gets compressed.
moveopenescclose