summaryrefslogtreecommitdiff
path: root/doc/source/reference/random/legacy.rst
blob: d9391e9e2bf12238e53a49d6336a7a7cdc69fce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
.. _legacy:

Legacy Random Generation
------------------------
The `~mtrand.RandomState` 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 NumPy.

`~mtrand.RandomState` 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
`~mtrand.RandomState.get_state`, and not the underlying bit generators
`state`, when accessing the state so that these extra values are saved.

.. warning::

  :class:`~randomgen.legacy.LegacyGenerator` only contains functions
  that have changed.  Since it does not contain other functions, it
  is not directly possible to replace :class:`~numpy.random.RandomState`.
  In order to full replace :class:`~numpy.random.RandomState`, it is
  necessary to use both :class:`~randomgen.legacy.LegacyGenerator`
  and :class:`~randomgen.generator.RandomGenerator` both driven
  by the same basic RNG. Methods present in :class:`~randomgen.legacy.LegacyGenerator`
  must be called from :class:`~randomgen.legacy.LegacyGenerator`.  Other Methods
  should be called from :class:`~randomgen.generator.RandomGenerator`.


.. code-block:: python

   from numpy.random import MT19937
   from numpy.random import RandomState

   # Use same seed
   rs = RandomState(12345)
   mt19937 = MT19937(12345)
   lg = RandomState(mt19937)

   # Identical output
   rs.standard_normal()
   lg.standard_normal()

   rs.random()
   lg.random()

   rs.standard_exponential()
   lg.standard_exponential()


.. currentmodule:: numpy.random.mtrand

.. autoclass:: RandomState
	:exclude-members:

Seeding and State
=================

.. autosummary::
   :toctree: generated/

   ~RandomState.get_state
   ~RandomState.set_state
   ~RandomState.seed

Simple random data
==================
.. autosummary::
   :toctree: generated/

   ~RandomState.rand
   ~RandomState.randn
   ~RandomState.randint
   ~RandomState.random_integers
   ~RandomState.random_sample
   ~RandomState.choice
   ~RandomState.bytes

Permutations
============
.. autosummary::
   :toctree: generated/

   ~RandomState.shuffle
   ~RandomState.permutation

Distributions
=============
.. autosummary::
   :toctree: generated/

   ~RandomState.beta
   ~RandomState.binomial
   ~RandomState.chisquare
   ~RandomState.dirichlet
   ~RandomState.exponential
   ~RandomState.f
   ~RandomState.gamma
   ~RandomState.geometric
   ~RandomState.gumbel
   ~RandomState.hypergeometric
   ~RandomState.laplace
   ~RandomState.logistic
   ~RandomState.lognormal
   ~RandomState.logseries
   ~RandomState.multinomial
   ~RandomState.multivariate_normal
   ~RandomState.negative_binomial
   ~RandomState.noncentral_chisquare
   ~RandomState.noncentral_f
   ~RandomState.normal
   ~RandomState.pareto
   ~RandomState.poisson
   ~RandomState.power
   ~RandomState.rayleigh
   ~RandomState.standard_cauchy
   ~RandomState.standard_exponential
   ~RandomState.standard_gamma
   ~RandomState.standard_normal
   ~RandomState.standard_t
   ~RandomState.triangular
   ~RandomState.uniform
   ~RandomState.vonmises
   ~RandomState.wald
   ~RandomState.weibull
   ~RandomState.zipf