1"""

2========================

3 Random Number Generation

4========================

5

6 Use ``default_rng()`` to create a `Generator` and call its methods.

7

8=============== =========================================================

9 Generator

10--------------- ---------------------------------------------------------

11 Generator Class implementing all of the random number distributions

12 default_rng Default constructor for ``Generator``

13=============== =========================================================

14

15============================================= ===

16 BitGenerator Streams that work with Generator

17--------------------------------------------- ---

18 MT19937

19 PCG64

20 PCG64DXSM

21 Philox

22 SFC64

23============================================= ===

24

25============================================= ===

26 Getting entropy to initialize a BitGenerator

27--------------------------------------------- ---

28 SeedSequence

29============================================= ===

30

31

32 Legacy

33------

34

35 For backwards compatibility with previous versions of numpy before 1.17, the

36 various aliases to the global `RandomState` methods are left alone and do not

37 use the new `Generator` API.

38

39==================== =========================================================

40 Utility functions

41-------------------- ---------------------------------------------------------

42 random Uniformly distributed floats over ``[0, 1)``

43 bytes Uniformly distributed random bytes.

44 permutation Randomly permute a sequence / generate a random sequence.

45 shuffle Randomly permute a sequence in place.

46 choice Random sample from 1-D array.

47==================== =========================================================

48

49==================== =========================================================

50 Compatibility

51 functions - removed

52 in the new API

53-------------------- ---------------------------------------------------------

54 rand Uniformly distributed values.

55 randn Normally distributed values.

56 ranf Uniformly distributed floating point numbers.

57 random_integers Uniformly distributed integers in a given range.

58 (deprecated, use ``integers(..., closed=True)`` instead)

59 random_sample Alias for `random_sample`

60 randint Uniformly distributed integers in a given range

61 seed Seed the legacy random number generator.

62==================== =========================================================

63

64==================== =========================================================

65 Univariate

66 distributions

67-------------------- ---------------------------------------------------------

68 beta Beta distribution over ``[0, 1]``.

69 binomial Binomial distribution.

70 chisquare :math:`\\chi^2` distribution.

71 exponential Exponential distribution.

72 f F (Fisher-Snedecor) distribution.

73 gamma Gamma distribution.

74 geometric Geometric distribution.

75 gumbel Gumbel distribution.

76 hypergeometric Hypergeometric distribution.

77 laplace Laplace distribution.

78 logistic Logistic distribution.

79 lognormal Log-normal distribution.

80 logseries Logarithmic series distribution.

81 negative_binomial Negative binomial distribution.

82 noncentral_chisquare Non-central chi-square distribution.

83 noncentral_f Non-central F distribution.

84 normal Normal / Gaussian distribution.

85 pareto Pareto distribution.

86 poisson Poisson distribution.

87 power Power distribution.

88 rayleigh Rayleigh distribution.

89 triangular Triangular distribution.

90 uniform Uniform distribution.

91 vonmises Von Mises circular distribution.

92 wald Wald (inverse Gaussian) distribution.

93 weibull Weibull distribution.

94 zipf Zipf's distribution over ranked data.

95==================== =========================================================

96

97==================== ==========================================================

98 Multivariate

99 distributions

100-------------------- ----------------------------------------------------------

101 dirichlet Multivariate generalization of Beta distribution.

102 multinomial Multivariate generalization of the binomial distribution.

103 multivariate_normal Multivariate generalization of the normal distribution.

104==================== ==========================================================

105

106==================== =========================================================

107 Standard

108 distributions

109-------------------- ---------------------------------------------------------

110 standard_cauchy Standard Cauchy-Lorentz distribution.

111 standard_exponential Standard exponential distribution.

112 standard_gamma Standard Gamma distribution.

113 standard_normal Standard normal distribution.

114 standard_t Standard Student's t-distribution.

115==================== =========================================================

116

117==================== =========================================================

118 Internal functions

119-------------------- ---------------------------------------------------------

120 get_state Get tuple representing internal state of generator.

121 set_state Set state of generator.

122==================== =========================================================

123

124

125"""

126__all__ = [

127 'beta',

128 'binomial',

129 'bytes',

130 'chisquare',

131 'choice',

132 'dirichlet',

133 'exponential',

134 'f',

135 'gamma',

136 'geometric',

137 'get_state',

138 'gumbel',

139 'hypergeometric',

140 'laplace',

141 'logistic',

142 'lognormal',

143 'logseries',

144 'multinomial',

145 'multivariate_normal',

146 'negative_binomial',

147 'noncentral_chisquare',

148 'noncentral_f',

149 'normal',

150 'pareto',

151 'permutation',

152 'poisson',

153 'power',

154 'rand',

155 'randint',

156 'randn',

157 'random',

158 'random_integers',

159 'random_sample',

160 'ranf',

161 'rayleigh',

162 'sample',

163 'seed',

164 'set_state',

165 'shuffle',

166 'standard_cauchy',

167 'standard_exponential',

168 'standard_gamma',

169 'standard_normal',

170 'standard_t',

171 'triangular',

172 'uniform',

173 'vonmises',

174 'wald',

175 'weibull',

176 'zipf',

177]

178

179# add these for module-freeze analysis (like PyInstaller)

180 from . import _pickle

181 from . import _common

182 from . import _bounded_integers

183

184 from ._generator import Generator, default_rng

185 from .bit_generator import SeedSequence, BitGenerator

186 from ._mt19937 import MT19937

187 from ._pcg64 import PCG64, PCG64DXSM

188 from ._philox import Philox

189 from ._sfc64 import SFC64

190 from .mtrand import *

191

192__all__ += ['Generator', 'RandomState', 'SeedSequence', 'MT19937',

193 'Philox', 'PCG64', 'PCG64DXSM', 'SFC64', 'default_rng',

194 'BitGenerator']

195

196

197 def __RandomState_ctor():

198 """Return a RandomState instance.

199

200 This function exists solely to assist (un)pickling.

201

202 Note that the state of the RandomState returned here is irrelevant, as this

203 function's entire purpose is to return a newly allocated RandomState whose

204 state pickle can set. Consequently the RandomState returned by this function

205 is a freshly allocated copy with a seed=0.

206

207 See https://github.com/numpy/numpy/issues/4763 for a detailed discussion

208

209 """

210 return RandomState(seed=0)

211

212

213 from numpy._pytesttester import PytestTester

214 test = PytestTester(__name__)

215 del PytestTester