{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Example\n\nFix a parameter $\\theta \u003e 0$.\nCustomers $1, 2, 3, \\ldots$ enter a restaurant with infinitely many tables, one at a time.\nCustomer $1$ sits at a new table.\nSuppose $n$ customers are seated, and the occupied tables hold $n_1, \\ldots, n_k$ customers, so $n_1 + \\cdots + n_k = n$.\nThen customer $n + 1$ sits at the $j$-th occupied table with probability $n_j / (n + \\theta)$, and at a new table with probability $\\theta / (n + \\theta)$.\nThese probabilities are nonnegative and sum to $(n + \\theta)/(n + \\theta) = 1$.\nThe seating of the first $n$ customers gives a random [[partition|08QMKTWF9T]] $\\Pi_n$ of $\\set{1, \\ldots, n}$, whose blocks are the tables.\n\nMultiplying the seating probabilities gives, for each partition $\\pi$ of $\\set{1, \\ldots, n}$ with $k$ blocks of sizes $n_1, \\ldots, n_k$,\n$$P(\\Pi_n = \\pi) = \\frac{\\theta^k \\, \\Gamma(\\theta)}{\\Gamma(\\theta + n)} \\prod_{j=1}^{k} (n_j - 1)!,$$\nwhere $\\Gamma$ is the [[gamma function|0H5SYBSED9]].\nTo check this, note that the denominators $\\theta, \\theta + 1, \\ldots, \\theta + n - 1$ multiply to $\\Gamma(\\theta + n)/\\Gamma(\\theta)$.\nEach table contributes the factor $\\theta$ when it is opened, and then the factors $1, 2, \\ldots, n_j - 1$ from the later customers who join it.\nThe right side depends only on the block sizes, so the law of $\\Pi_n$ is invariant under permutations of $\\set{1, \\ldots, n}$.\nIn this sense the random partition is [[exchangeable|4MR4YJS1ZD]].\n\nFor $n = 2$, customers $1$ and $2$ share a table with probability $1/(1 + \\theta)$.\nThe number $K_n$ of occupied tables after $n$ customers has mean\n$$E[K_n] = \\sum_{i=0}^{n-1} \\frac{\\theta}{\\theta + i},$$\nwhich grows like $\\theta \\log n$.\n\n## Remarks\n\nLet $G$ follow a [[Dirichlet process|XT4SWG6J7N]] with concentration $\\theta$ and a base measure without atoms.\nGiven $G$, draw $X_1, X_2, \\ldots$ independently from $G$, and group the indices $i$ by equal values $X_i$.\nThe resulting random partition has the law of the Chinese restaurant process with parameter $\\theta$.\nThis is why the process is used to sample from Dirichlet process mixture models.\n\n## Explanations\n\n### L1 human\n\nPicture a restaurant where each new guest either joins a table or starts a new one.\nA busy table attracts guests in proportion to how many already sit there, so the rich get richer.\nThe parameter $\\theta$ measures how much guests like to start fresh tables.\nWith $\\theta = 1$, the second guest joins the first with probability $1/2$.\nThe result is a random way of splitting the guests into groups.\n",
  "commit": "547b6eddb8f2feb8d579f2d633d22a27b7e132fc",
  "front": {
    "illustrates": [
      "XT4SWG6J7N",
      "4MR4YJS1ZD"
    ],
    "kind": "example",
    "msc": [
      "60G09",
      "60C05",
      "62G05"
    ],
    "name": "Chinese restaurant process",
    "same_as": {
      "wikidata": "Q4407236",
      "wikipedia": "Chinese restaurant process"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Chinese_restaurant_process"
      }
    ],
    "tag": "2SEF8QTYQF"
  },
  "kind": "example",
  "link": "https://math2.tamnd.com/node/2SEF8QTYQF/",
  "links": [
    {
      "field": "illustrates",
      "target": "XT4SWG6J7N"
    },
    {
      "field": "illustrates",
      "target": "4MR4YJS1ZD"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/2SEF8QTYQF.md",
  "msc": [
    "60G09",
    "60C05",
    "62G05"
  ],
  "name": "Chinese restaurant process",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/2SE/2SEF8QTYQF.md",
  "status": null,
  "tag": "2SEF8QTYQF",
  "uri": "m2://2SEF8QTYQF",
  "url": "https://math2.tamnd.com/wiki/chinese-restaurant-process/",
  "writing": {
    "tag": "2SEF8QTYQF",
    "kind": "example",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
