{
  "slug": "prediction-by-partial-matching",
  "term": "Prediction by partial matching",
  "aliases": [
    "PPM"
  ],
  "definition": "Prediction by partial matching models symbols from preceding contexts, escaping to shorter contexts when the current model cannot encode a symbol.",
  "note": "Coding: PPM predicts probabilities; an arithmetic coder represents the events. An escape is a model event, not necessarily a reserved input byte. Encoder and decoder must agree on model updates. [cleary97]\n\nTwo exclusions: Coding exclusion removes symbols already ruled out by a higher-context escape. Update exclusion instead omits counter increments below the context that successfully predicted the symbol. They affect different stages. [moffat90]\n\nExample: For context a with counts a:3,b:1, and an empty-context model a:5,b:2,c:1, method-C escape counts are 2 and 3. Coding c has path probability (2/6)*(1/4)=1/12 with coding exclusion, versus (2/6)*(1/11)=1/33 without it. These are model probabilities, not measured file sizes. [example]\n\nLonger contexts: More history can mean more escapes, not better compression. PPM* removes a fixed order limit but still needs a context-selection policy; the 1997 paper uses the shortest deterministic context when one exists. [cleary97]\n\nImplementation: Moffat uses move-to-front lists to search context statistics, a different role from emitting MTF ranks. The 7z format documents a PPMdH-derived coding method. [moffat90] [sevenzip]",
  "related": [
    "lossless-compression",
    "burrows-wheeler-transform",
    "move-to-front"
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "PPM names a modelling family, not an interchangeable archive format. The example omits bitstream coding, framing and finite-precision arithmetic.",
      "citationIds": [
        "example"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-18",
  "citations": [
    {
      "id": "moffat90",
      "title": "Moffat: Implementing the PPM Data Compression Scheme, IEEE Transactions on Communications 38(11), 1917-1921 (1990), sections II-III",
      "url": "https://cs.nyu.edu/home/people/in_memoriam/roweis/csc310-2006/extras/implementing_ppm.pdf",
      "accessed": "2026-11-18"
    },
    {
      "id": "cleary97",
      "title": "Cleary and Teahan: Unbounded Length Contexts for PPM, The Computer Journal 40(2/3), 67-75 (1997), sections 2-3 and 5",
      "url": "https://www.cs.ucf.edu/courses/cap5015/Cleary.pdf",
      "accessed": "2026-11-18"
    },
    {
      "id": "example",
      "title": "Hesela: PPM coding and update exclusion, exact executable example and tests",
      "url": "https://hesela.dev/research/ppm-exclusion/README.md",
      "accessed": "2026-11-18"
    },
    {
      "id": "sevenzip",
      "title": "7-Zip: 7z Format, integrated compression methods",
      "url": "https://www.7-zip.org/7z.html",
      "accessed": "2026-11-18"
    }
  ],
  "provenance": [
    "Source synthesis and an original hypothetical count example; not a compressor benchmark or replication of a paper's measurements.",
    "The 1990 and 1997 papers were read. Full-text retrieval of the 1984 paper failed; no claim depends on its abstract alone."
  ]
}
