{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:random:legacy",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " provides access to legacy generators. This generator is considered frozen and will have no further improvements.  It is guaranteed to produce the same values as the final point release of NumPy v1.16. These all depend on Box-Muller normals or inverse CDF exponentials or gammas. This class should only be used if it is essential to have randoms that are identical to what would have been produced by previous versions of NumPy."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " adds additional information to the state which is required when using Box-Muller normals since these are produced in pairs. It is important to use "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState.get_state",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and not the underlying bit generators "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "state",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", when accessing the state so that these extra values are saved."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Although we provide the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "MT19937",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " BitGenerator for use independent of "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", note that its default seeding uses "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "SeedSequence",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " rather than the legacy seeding algorithm. "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will use the legacy seeding algorithm. The methods to use the legacy seeding algorithm are currently private as the main reason to use them is just to implement "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". However, one can reset the state of "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "MT19937",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " using the state of the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "from numpy.random import MT19937\nfrom numpy.random import RandomState\n\nrs = RandomState(12345)\nmt19937 = MT19937()\nmt19937.state = rs.get_state()\nrs2 = RandomState(mt19937)\n\n# Same output\nrs.standard_normal()\nrs2.standard_normal()\n\nrs.random()\nrs2.random()\n\nrs.standard_exponential()\nrs2.standard_exponential()",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Legacy random generation"
        }
      ],
      "level": 0,
      "target": "legacy"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ~RandomState.get_state\n    ~RandomState.set_state\n    ~RandomState.seed",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Seeding and state"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ~RandomState.rand\n    ~RandomState.randn\n    ~RandomState.randint\n    ~RandomState.random_integers\n    ~RandomState.random_sample\n    ~RandomState.choice\n    ~RandomState.bytes",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Simple random data"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ~RandomState.shuffle\n    ~RandomState.permutation",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Permutations"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    ~RandomState.beta\n    ~RandomState.binomial\n    ~RandomState.chisquare\n    ~RandomState.dirichlet\n    ~RandomState.exponential\n    ~RandomState.f\n    ~RandomState.gamma\n    ~RandomState.geometric\n    ~RandomState.gumbel\n    ~RandomState.hypergeometric\n    ~RandomState.laplace\n    ~RandomState.logistic\n    ~RandomState.lognormal\n    ~RandomState.logseries\n    ~RandomState.multinomial\n    ~RandomState.multivariate_normal\n    ~RandomState.negative_binomial\n    ~RandomState.noncentral_chisquare\n    ~RandomState.noncentral_f\n    ~RandomState.normal\n    ~RandomState.pareto\n    ~RandomState.poisson\n    ~RandomState.power\n    ~RandomState.rayleigh\n    ~RandomState.standard_cauchy\n    ~RandomState.standard_exponential\n    ~RandomState.standard_gamma\n    ~RandomState.standard_normal\n    ~RandomState.standard_t\n    ~RandomState.triangular\n    ~RandomState.uniform\n    ~RandomState.vonmises\n    ~RandomState.wald\n    ~RandomState.weibull\n    ~RandomState.zipf",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Distributions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Many of the RandomState methods above are exported as functions in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.random",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.random"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " This usage is discouraged, as it is implemented via a global "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "RandomState",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " instance which is not advised on two counts:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "It uses global state, which means results will change as the code changes"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "It uses a "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "RandomState",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " rather than the more modern "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "Generator",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For backward compatible legacy reasons, we will not change this."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n\n    beta\n    binomial\n    bytes\n    chisquare\n    choice\n    dirichlet\n    exponential\n    f\n    gamma\n    geometric\n    get_state\n    gumbel\n    hypergeometric\n    laplace\n    logistic\n    lognormal\n    logseries\n    multinomial\n    multivariate_normal\n    negative_binomial\n    noncentral_chisquare\n    noncentral_f\n    normal\n    pareto\n    permutation\n    poisson\n    power\n    rand\n    randint\n    randn\n    random\n    random_integers\n    random_sample\n    ranf\n    rayleigh\n    sample\n    seed\n    set_state\n    shuffle\n    standard_cauchy\n    standard_exponential\n    standard_gamma\n    standard_normal\n    standard_t\n    triangular\n    uniform\n    vonmises\n    wald\n    weibull\n    zipf\n",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Functions in "
        },
        {
          "__type": "InlineRole",
          "__tag": 4003,
          "value": "numpy.random",
          "domain": null,
          "role": null,
          "inventory": null
        }
      ],
      "level": 1,
      "target": "functions-in-numpy-random"
    }
  ],
  "local_refs": []
}