Skip to contents

ONLINE: the rotation and codebook are fixed in advance, so a vector is quantized on arrival with no knowledge of those that follow. The codebook is Lloyd-Max for a standard normal, rescaled by ||x||/sqrt(d).

Usage

Kvquant(x, b = 2, seed = 1)

Arguments

x

The vector to quantize.

b

Bits per coordinate, b >= 1.

seed

Seed for the pinned rotation.

Value

List with idx, reconstruction, codebook, mse, relative_mse, bound, within_bound, d, b.

Details

Formula: y <- Pi . x; idx_j <- argmin_k |y_j - c_k|; ytilde_j <- c_{idx_j}; xtilde <- Pi' . ytilde

References

Zandieh et al., arXiv:2504.19874, Algorithm 1 lines 2-11 and Theorem 1. The paper specifies the codebook only as the MSE-minimising centroids; the Lloyd-Max construction is documented in the batch helper .kvmse_codebook.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Kvquant(V)
#> $idx
#> [1] 2 3 2 1 0 3 1 2
#> 
#> $reconstruction
#> [1] 1.565388 1.143727 2.191674 3.068693 6.895725 4.348964 4.920615 9.562078
#> 
#> $codebook
#> [1] -7.600649 -2.265404  2.293388  7.624837
#> 
#> $mse
#> [1] 15.65722
#> 
#> $relative_mse
#> [1] 0.07675106
#> 
#> $bound
#> [1] 0.1700437
#> 
#> $within_bound
#> [1] 1
#> 
#> $d
#> [1] 8
#> 
#> $b
#> [1] 2
#> 
#> $method
#> [1] "TurboQuant_mse, arXiv:2504.19874 Algorithm 1"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"