Expand description
Codebook lookup, Beta PDF, and pre-computed tables for Lloyd-Max quantization.
After applying a random rotation to a d-dimensional unit vector, each coordinate follows a Beta-type distribution on [-1, 1]:
f_X(x) = Gamma(d/2) / (sqrt(pi) * Gamma((d-1)/2)) * (1 - x^2)^((d-3)/2)This module stores pre-computed Lloyd-Max codebooks for common (bits, dim)
pairs and provides lookup / nearest-centroid queries. The generation
algorithm itself lives in the [gen] sub-module.
Structs§
- Codebook
- A static codebook: sorted centroids and the decision boundaries between them. For k centroids there are k-1 interior boundaries; the outer boundaries are implicitly -1 and +1.
Functions§
- beta_
pdf - Evaluate the Beta-type PDF of a rotated unit-vector coordinate.
- generate_
codebook - Run the Lloyd-Max algorithm from scratch for arbitrary
(bits, dim). - get_
codebook - Return a pre-computed
Codebookfor the given(bits, dim)pair. - nearest_
centroid - Find the index of the nearest centroid for a scalar
value.