blob: b9bfabcc7df4cf3cd97bd4f0eca89d570b3e7529 (
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
|
Legacy Random Generation
------------------------
The :class:`~legacy.LegacyGenerator` provides access to
legacy generators. 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.
:class:`~legacy.LegacyGenerator` add additional information
to the state which is required when using Box-Muller normals since these
are produced in pairs. It is important to use
:attr:`~legacy.LegacyGenerator.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 direclty 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.legacy import LegacyGenerator
from numpy.random import RandomState
# Use same seed
rs = RandomState(12345)
mt19937 = MT19937(12345)
rg = RandomGenerator(mt19937)
lg = LegacyGenerator(mt19937)
# Identical output
rs.standard_normal()
lg.standard_normal()
rs.random_sample()
rg.random_sample()
rs.standard_exponential()
lg.standard_exponential()
.. currentmodule:: numpy.random.legacy
.. autoclass:: LegacyGenerator
:exclude-members:
Seeding and State
=================
.. autosummary::
:toctree: generated/
~LegacyGenerator.get_state
~LegacyGenerator.set_state
Simple random data
==================
.. autosummary::
:toctree: generated/
~LegacyGenerator.randn
~LegacyGenerator.randint
~LegacyGenerator.random_integers
~LegacyGenerator.random_sample
~LegacyGenerator.choice
~LegacyGenerator.bytes
Permutations
============
.. autosummary::
:toctree: generated/
~LegacyGenerator.shuffle
~LegacyGenerator.permutation
Distributions
=============
.. autosummary::
:toctree: generated/
~LegacyGenerator.beta
~LegacyGenerator.chisquare
~LegacyGenerator.dirichlet
~LegacyGenerator.exponential
~LegacyGenerator.f
~LegacyGenerator.gamma
~LegacyGenerator.lognormal
~LegacyGenerator.multivariate_normal
~LegacyGenerator.negative_binomial
~LegacyGenerator.noncentral_chisquare
~LegacyGenerator.noncentral_f
~LegacyGenerator.normal
~LegacyGenerator.pareto
~LegacyGenerator.power
~LegacyGenerator.standard_cauchy
~LegacyGenerator.standard_exponential
~LegacyGenerator.standard_gamma
~LegacyGenerator.standard_normal
~LegacyGenerator.standard_t
~LegacyGenerator.wald
~LegacyGenerator.weibull
~LegacyGenerator.zipf
|