{
  "id": "enwiki-001343760864",
  "slug": "pyramid-vector-quantization",
  "title": "Pyramid vector quantization",
  "qid": "",
  "lead": "Pyramid vector quantization (PVQ) is a method used in audio and video codecs to quantize and transmit unit vectors, i.e. vectors whose magnitudes are known to the decoder but whose directions are unknown. PVQ may also be used as part of a gain/shape quantization scheme, whereby the magnitude and direction of a vector are quantized separately from each other. PVQ was initially described in 1986 in the paper \"A Pyramid Vector Quantizer\" by Thomas R. Fischer. . One caveat of PVQ is that it operates under the taxicab distance (L1-norm). Conversion to/from the more familiar Euclidean distance (L2-norm) is possible via vector projection, though results in a less uniform distribution of quantization points (the poles of the Euclidean n-sphere become denser than non-poles). No efficient algorithm for the ideal (i.e., uniform) vector quantization of the Euclidean n-sphere is known as of 2010. This non-uniformity can be reduced by applying deformation like coordinate-wise power before projection, reducing mean-squared quantization error by ~10%. PVQ is used in the CELT audio codec (inherited into Opus) and the Daala video codec.",
  "body": "Pyramid vector quantization (PVQ) is a method used in audio and video codecs to quantize and transmit unit vectors, i.e. vectors whose magnitudes are known to the decoder but whose directions are unknown. PVQ may also be used as part of a gain/shape quantization scheme, whereby the magnitude and direction of a vector are quantized separately from each other. PVQ was initially described in 1986 in the paper \"A Pyramid Vector Quantizer\" by Thomas R. Fischer. . One caveat of PVQ is that it operates under the taxicab distance (L1-norm). Conversion to/from the more familiar Euclidean distance (L2-norm) is possible via vector projection, though results in a less uniform distribution of quantization points (the poles of the Euclidean n-sphere become denser than non-poles). No efficient algorithm for the ideal (i.e., uniform) vector quantization of the Euclidean n-sphere is known as of 2010. This non-uniformity can be reduced by applying deformation like coordinate-wise power before projection, reducing mean-squared quantization error by ~10%. PVQ is used in the CELT audio codec (inherited into Opus) and the Daala video codec. S(N,K)=\\left\\{\\vec{p} \\in \\mathbb{Z}^N : \\left\\| \\vec{p} \\right\\|_1 = K\\right\\} where \\left\\| \\vec{p} \\right\\|_1 denotes the L1-norm of \\vec{p} . As it stands, the set tesselates the surface of an -dimensional pyramid. If desired, we may reshape it into a sphere by \"projecting\" the points onto the sphere, i.e. by normalizing them: S_\\text{sphere}(N,K)=\\left\\{\\frac{\\vec{p}}{\\left\\| \\vec{p} \\right\\|_2} : \\vec{p} \\in S(N,K)\\right\\} where \\left\\| \\vec{p} \\right\\|_2 denotes the L2-norm of \\vec{p} . Increasing the parameter results in more quantization points, and hence typically yields a more \"accurate\" approximation of the original unit vector \\vec{v} at the cost of larger integer codewords that require more bits to transmit. Suppose we wish to quantize three-dimensional unit vectors using the parameter =2. Our codebook becomes: | |} (0.707 = \\sqrt{2}/2 rounded to 3 decimal places.) Now, suppose we wish to transmit the unit vector (rounded here to 3 decimal places, for clarity). According to our codebook, the closest point we can pick is codeword 13 ( ), located approximately 0.381 units away from our original point. Increasing the parameter results in a larger codebook, which typically increases the reconstruction accuracy. For example, based on the Python code below, =5 (codebook size: 102) yields an error of only 0.097 units, and =20 (codebook size: 1602) yields an error of only 0.042 units. import itertools import math from typing import NamedTuple class PVQEntry(NamedTuple): codeword: int point: tuple[int, ...] normalizedPoint: tuple[float, ...] def create_pvq_codebook(n: int, k: int) -> list[PVQEntry]: \"\"\" Naive algorithm to generate an n-dimensional PVQ codebook with k pulses. Runtime complexity: O(k**n) \"\"\" ret = [] for p in itertools.product(range(-k, k + 1), repeat=n): if sum(abs(x) for x in p) == k: norm = math.sqrt(sum(x ** 2 for x in p)) q = tuple(x / norm for x in p) ret.append(PVQEntry(len(ret), p, q)) return ret def search_pvq_codebook( codebook: list[PVQEntry], p: tuple[float, ...] ) -> tuple[PVQEntry, float]: \"\"\" Naive algorithm to search the PVQ codebook. Returns the point in the codebook that's \"closest\" to p, according to the Euclidean distance.) \"\"\" ret = None min_dist = None for entry in codebook: q = entry.normalizedPoint dist = math.sqrt(sum((q[j] - p[j]) ** 2 for j in range(len(p)))) if min_dist is None or dist None: n = len(p) codebook = create_pvq_codebook(n, k) print(\"Number of codebook entries: \" + str(len(codebook))) entry, dist = search_pvq_codebook(codebook, p) print(\"Best entry: \" + str(entry)) print(\"Distance: \" + str(dist)) phi = 1.2 theta = 5.4 x = math.sin(phi) * math.cos(theta) y = math.sin(phi) * math.sin(theta) z = math.cos(phi) p = (x, y, z) example(p, 2) example(p, 5) example(p, 20) V(N,K) = V(N-1,K) + V(N,K-1) + V(N-1,K-1) with V(N,0) = 1 for all N \\ge 0 and V(0,K) = 0 for all K \\ne 0 . A closed-form solution is given by V(N,K) = 2N \\cdot {}_2F_1 (1-K,1-N;2;2). where {}_2F_1 is the hypergeometric function.",
  "categories": [
    "23221442"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1343760864",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1773636536.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001343760864",
    "type": "webpage",
    "title": "Pyramid vector quantization",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/pyramid-vector-quantization",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          20
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          20
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001343760864",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1343760864",
    "note": "Immutable snapshot enwiki-001343760864"
  }
}