LEX: Fast scalar quantization by grouping and local exchanges

Least-squares scalar quantization represents N values by k bin means while minimizing squared error. Exact algorithms solve this problem in one dimension, but large inputs can still be costly in time or memory. The LEX algorithm merges adjacent values into a smaller set of coarse groups, partitions the groups' weighted means by an exact dynamic program (DP), and refines the resulting cuts through single and paired boundary moves. Merge steps are batched for speed, and values sharing a rounded key can be grouped to accelerate the merges. We compare LEX with a table-free exact solver on three synthetic distributions, an audio recording, and two neural-network weight matrices, with N up to about 8.4 million and k ≤ 512. Across 81 fits, the relative excess error was at most 0.0040% for full-precision LEX. Across 102 fits, it was at most 0.0056% for precision-grouped LEX. On four inputs of 8.2 to 8.4 million values, with k ∈ {16, 32, 64, 128, 256, 512}, precision-grouped LEX was 54 to 169 times faster than the exact solver, excluding the shared sort, and 5.8 to 20 times faster including it. On those inputs its peak process memory was 99 to 223 MiB, against 510 to 1,299 MiB for the exact solver. The LEX C++ library has a Scala port and Python and R interfaces.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-11-25
DOI
https://doi.org/10.5281/zenodo.24543219
Primary Topic
Advanced Clustering Algorithms Research
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

LEX: Fast scalar quantization by grouping and local exchanges

N. Sriram
Zenodo (CERN European Organization for Nuclear Research)
Advanced Clustering Algorithms Research
preprint

LEX: Fast scalar quantization by grouping and local exchanges

N. Sriram
preprint en

Abstract

Least-squares scalar quantization represents N values by k bin means while minimizing squared error. Exact algorithms solve this problem in one dimension, but large inputs can still be costly in time or memory. The LEX algorithm merges adjacent values into a smaller set of coarse groups, partitions the groups' weighted means by an exact dynamic program (DP), and refines the resulting cuts through single and paired boundary moves. Merge steps are batched for speed, and values sharing a rounded key can be grouped to accelerate the merges. We compare LEX with a table-free exact solver on three synthetic distributions, an audio recording, and two neural-network weight matrices, with N up to about 8.4 million and k ≤ 512. Across 81 fits, the relative excess error was at most 0.0040% for full-precision LEX. Across 102 fits, it was at most 0.0056% for precision-grouped LEX. On four inputs of 8.2 to 8.4 million values, with k ∈ {16, 32, 64, 128, 256, 512}, precision-grouped LEX was 54 to 169 times faster than the exact solver, excluding the shared sort, and 5.8 to 20 times faster including it. On those inputs its peak process memory was 99 to 223 MiB, against 510 to 1,299 MiB for the exact solver. The LEX C++ library has a Scala port and Python and R interfaces.

Zenodo (CERN European Organization for Nuclear Research)
Advanced Clustering Algorithms Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon