{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $q$ be a real number to be computed.\nA *(plain) Monte Carlo method* for $q$ consists of the following data:\n\n1. a [[random variable|0PNRKMRC55]] $Y$ with $\\mathbb E\\abs{Y} \u003c \\infty$ and [[expected value|0WQNRCNY3M]] $\\mathbb E Y = q$;\n2. a procedure that produces [[independent and identically distributed|00MRN0FARV]] random variables $Y_1, Y_2, \\ldots$ with the distribution of $Y$;\n3. for each sample size $n \\ge 1$, the estimate\n$$\\hat q_n = \\frac{1}{n} \\sum_{i=1}^{n} Y_i.$$\n\nMore generally, a *Monte Carlo method* is any algorithm whose output is a random variable used to approximate a deterministic quantity.\n\n## Remarks\n\nExample: $q = \\pi/4$ is the probability that a point $(U, V)$ uniform on $[0, 1]^2$ satisfies $U^2 + V^2 \\le 1$.\nSo $Y = 1$ if $U^2 + V^2 \\le 1$ and $Y = 0$ otherwise satisfies clause 1, since $Y$ is bounded and $\\mathbb E Y = \\pi/4$, and independent uniform points give clause 2.\nNon-example: $Y = 1/U$ with $U$ uniform on $(0, 1)$ has $\\mathbb E\\abs{Y} = \\int_0^1 u^{-1}\\, du = \\infty$, so clause 1 fails and the averages $\\hat q_n$ tend to $+\\infty$ almost surely.\nThe estimate $\\hat q_n$ is unbiased, $\\mathbb E \\hat q_n = q$, and if $\\operatorname{Var} Y = \\sigma^2 \u003c \\infty$ its standard deviation is $\\sigma/\\sqrt{n}$.\nIn practice clause 2 is realised with a pseudorandom number generator, so the samples are only imitations of independent random variables.\nMethods based on Markov chains, such as Markov chain Monte Carlo, fit the general sense but not the plain one, since their samples are dependent.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "HWP11G3HTN",
    "kind": "definition",
    "msc": [
      "65C05",
      "11K45"
    ],
    "name": "Monte Carlo method",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Monte_Carlo_method"
      }
    ],
    "tag": "W4MT7K2QTF",
    "uses": [
      "0PNRKMRC55",
      "0WQNRCNY3M",
      "00MRN0FARV"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/W4MT7K2QTF/",
  "links": [
    {
      "field": "defines",
      "target": "HWP11G3HTN"
    },
    {
      "field": "uses",
      "target": "0PNRKMRC55"
    },
    {
      "field": "uses",
      "target": "0WQNRCNY3M"
    },
    {
      "field": "uses",
      "target": "00MRN0FARV"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/W4MT7K2QTF.md",
  "msc": [
    "65C05",
    "11K45"
  ],
  "name": "Monte Carlo method",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/W4M/W4MT7K2QTF.md",
  "status": null,
  "tag": "W4MT7K2QTF",
  "uri": "m2://W4MT7K2QTF",
  "url": "https://tamnd.github.io/math2/wiki/monte-carlo-method-definition/",
  "writing": {
    "tag": "W4MT7K2QTF",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
