{
  "aliases": null,
  "backlinks": [
    {
      "field": "uses",
      "target": "2DSN343YYW"
    }
  ],
  "body": "\n## Statement\n\nLet $d \\ge 1$, let $\\Omega \\subseteq \\R^d$ be a measurable set with [[Lebesgue measure|2Z2QVWZ262]] $V$, $0 \u003c V \u003c \\infty$, and let $f \\colon \\Omega \\to \\R$ be integrable, with $I = \\int_\\Omega f(x)\\, dx$.\nLet $X_1, X_2, \\ldots$ be [[independent and identically distributed|00MRN0FARV]] random points with the [[uniform distribution|0AREFQ9Z65]] on $\\Omega$, and let\n$$Q_n = \\frac{V}{n} \\sum_{i=1}^{n} f(X_i).$$\nThen:\n\n1. $\\mathbb E Q_n = I$ for every $n \\ge 1$;\n2. $Q_n \\to I$ almost surely as $n \\to \\infty$;\n3. if moreover $\\int_\\Omega f^2 \u003c \\infty$, then $\\operatorname{Var} Q_n = V^2 \\sigma^2 / n$, where $\\sigma^2 = \\operatorname{Var} f(X_1) = \\frac{1}{V}\\int_\\Omega f^2 - \\frac{I^2}{V^2}$;\n4. under the hypothesis of clause 3 and $\\sigma \u003e 0$, $\\sqrt{n}\\,(Q_n - I) / (V \\sigma)$ converges in distribution to the standard normal distribution.\n\n## Remarks\n\nThe density of $X_1$ is $1/V$ on $\\Omega$, so $\\mathbb E[V f(X_1)] = \\int_\\Omega f$; this gives clause 1.\nClause 2 is the [[strong law of large numbers|0DFWHQ839T]] for the variables $V f(X_i)$, and clause 4 is the [[central limit theorem|0EPZC4Z1FC]].\nClause 3 follows from the [[variance of a sum of independent random variables|0V0778DCW9]].\nSo the root-mean-square error is $V\\sigma / \\sqrt{n}$; the rate $n^{-1/2}$ does not depend on the dimension $d$ or on the smoothness of $f$.\nExample: for $f(x) = x^2$ on $\\Omega = [0, 1]$ one has $I = 1/3$ and $\\sigma^2 = 1/5 - 1/9 = 4/45$, so with $n = 10^4$ the standard error is about $0.003$.\nIn practice $\\sigma$ is unknown and is replaced by the sample standard deviation, which gives approximate confidence intervals.\nWithout square-integrability clause 3 fails, and the convergence in clause 2 may be much slower than $n^{-1/2}$.\n\n## Explanations\n\n### L1 human\n\nTo find the integral of a function over a region, pick many random points in the region, average the function values, and multiply by the volume.\nOn average this gives exactly the right answer, and the scatter of the answer shrinks like one over the square root of the number of points.\nThe remarkable feature is that this rate is the same in dimension $1$ and in dimension $1000$.\nGrid-based rules, by contrast, need exponentially many points as the dimension grows.\n\n### L2 human\n\nThis is the basic [[Monte Carlo method|HWP11G3HTN]] applied to $Y = V f(X)$ with $X$ uniform.\nIn low dimension and for smooth $f$, classical quadrature rules converge much faster than $n^{-1/2}$, so Monte Carlo is mainly useful when $d$ is large or $f$ is rough.\nVariance reduction techniques, such as importance sampling, control variates and stratification, keep the rate $n^{-1/2}$ but reduce the constant $\\sigma$.\nQuasi-Monte Carlo methods replace the random points by deterministic low-discrepancy points.\nFor functions of bounded variation in the sense of Hardy and Krause, they reach a rate close to $n^{-1}$.\nUniform sampling on $\\Omega$ is often replaced by sampling from another density, which is the idea of importance sampling.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "HWP11G3HTN"
    ],
    "kind": "statement",
    "msc": [
      "65C05",
      "65D30"
    ],
    "name": "Monte Carlo integration",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q39879",
      "wikipedia": "Monte Carlo integration"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Monte_Carlo_integration"
      }
    ],
    "tag": "DAR3QJ5H7Y",
    "uses": [
      "HWP11G3HTN",
      "2Z2QVWZ262",
      "0AREFQ9Z65",
      "00MRN0FARV",
      "0477R9PYAE",
      "0DFWHQ839T",
      "0EPZC4Z1FC",
      "0V0778DCW9"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/DAR3QJ5H7Y/",
  "links": [
    {
      "field": "about",
      "target": "HWP11G3HTN"
    },
    {
      "field": "uses",
      "target": "HWP11G3HTN"
    },
    {
      "field": "uses",
      "target": "2Z2QVWZ262"
    },
    {
      "field": "uses",
      "target": "0AREFQ9Z65"
    },
    {
      "field": "uses",
      "target": "00MRN0FARV"
    },
    {
      "field": "uses",
      "target": "0477R9PYAE"
    },
    {
      "field": "uses",
      "target": "0DFWHQ839T"
    },
    {
      "field": "uses",
      "target": "0EPZC4Z1FC"
    },
    {
      "field": "uses",
      "target": "0V0778DCW9"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/DAR3QJ5H7Y.md",
  "msc": [
    "65C05",
    "65D30"
  ],
  "name": "Monte Carlo integration",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/DAR/DAR3QJ5H7Y.md",
  "status": null,
  "tag": "DAR3QJ5H7Y",
  "uri": "m2://DAR3QJ5H7Y",
  "url": "https://tamnd.github.io/math2/wiki/monte-carlo-integration/",
  "writing": {
    "tag": "DAR3QJ5H7Y",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
