{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Description\n\nThe Mersenne Twister is a [[pseudorandom number generator|C5FG6ARWVV]] designed by Makoto Matsumoto and Takuji Nishimura.\nIts standard version, MT19937, works with $32$-bit words.\nIts state is an array of $624$ words, that is $19\\,968$ bits, of which $19\\,937$ bits are effective.\nThe transition function is linear over the [[field with two elements|0ZXZ82FTX2]] $\\F_2$.\nIt combines three words of the array by shifts, masks and exclusive or, in a twisted generalised feedback shift register recurrence.\nThe output function applies a fixed invertible linear map, the tempering, to the newest word.\nIt fits the definition of a generator: the state space is finite, and the transition and output are fixed maps.\nThe seed determines the initial array.\nIts period is $2^{19937} - 1$, which is a [[Mersenne prime|0F3Z22M2GT]]; this is where the name comes from.\nIts outputs are $623$-dimensionally equidistributed to $32$-bit accuracy.\nThat is, over a full period every $623$-tuple of consecutive $32$-bit outputs occurs equally often, except that the all-zero tuple occurs once less.\n\n## Remarks\n\nBecause the generator is linear over $\\F_2$, $624$ consecutive outputs determine the whole state, so all later outputs can be predicted.\nIt is therefore not suitable for cryptography.\nLinearity also makes it fail some statistical tests based on linear complexity, although these rarely matter in simulation.\nThe large state means it can take many steps to recover from a seed with mostly zero bits.\n\n## Explanations\n\n### L1 human\n\nThe Mersenne Twister is the default random number generator of many programming languages and libraries, for example in Python.\nIt keeps a large hidden table of bits and stirs it with cheap bit operations at each step.\nThe sequence repeats only after $2^{19937} - 1$ outputs, a number with about $6000$ decimal digits, so no computation will ever see it repeat.\nIt is fast and statistically good for simulations, but a clever observer who sees enough outputs can predict the rest.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "instance_of": [
      "C5FG6ARWVV"
    ],
    "kind": "object",
    "msc": [
      "65C10",
      "11K45"
    ],
    "name": "Mersenne Twister",
    "same_as": {
      "wikidata": "Q1196406",
      "wikipedia": "Mersenne Twister"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Mersenne_Twister"
      }
    ],
    "tag": "YVEA283NZW"
  },
  "kind": "object",
  "link": "https://tamnd.github.io/math2/node/YVEA283NZW/",
  "links": [
    {
      "field": "instance_of",
      "target": "C5FG6ARWVV"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/YVEA283NZW.md",
  "msc": [
    "65C10",
    "11K45"
  ],
  "name": "Mersenne Twister",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/YVE/YVEA283NZW.md",
  "status": null,
  "tag": "YVEA283NZW",
  "uri": "m2://YVEA283NZW",
  "url": "https://tamnd.github.io/math2/wiki/mersenne-twister/",
  "writing": {
    "tag": "YVEA283NZW",
    "kind": "object",
    "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
      }
    ]
  }
}
