123 lines
5.4 KiB
Python
123 lines
5.4 KiB
Python
|
"""
|
||
|
========================
|
||
|
Random Number Generation
|
||
|
========================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Utility functions
|
||
|
==============================================================================
|
||
|
random Uniformly distributed values of a given shape.
|
||
|
bytes Uniformly distributed random bytes.
|
||
|
random_integers Uniformly distributed integers in a given range.
|
||
|
random_sample Uniformly distributed floats in a given range.
|
||
|
random Alias for random_sample
|
||
|
ranf Alias for random_sample
|
||
|
sample Alias for random_sample
|
||
|
choice Generate a weighted random sample from a given array-like
|
||
|
permutation Randomly permute a sequence / generate a random sequence.
|
||
|
shuffle Randomly permute a sequence in place.
|
||
|
seed Seed the random number generator.
|
||
|
==================== =========================================================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Compatibility functions
|
||
|
==============================================================================
|
||
|
rand Uniformly distributed values.
|
||
|
randn Normally distributed values.
|
||
|
ranf Uniformly distributed floating point numbers.
|
||
|
randint Uniformly distributed integers in a given range.
|
||
|
==================== =========================================================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Univariate distributions
|
||
|
==============================================================================
|
||
|
beta Beta distribution over ``[0, 1]``.
|
||
|
binomial Binomial distribution.
|
||
|
chisquare :math:`\\chi^2` distribution.
|
||
|
exponential Exponential distribution.
|
||
|
f F (Fisher-Snedecor) distribution.
|
||
|
gamma Gamma distribution.
|
||
|
geometric Geometric distribution.
|
||
|
gumbel Gumbel distribution.
|
||
|
hypergeometric Hypergeometric distribution.
|
||
|
laplace Laplace distribution.
|
||
|
logistic Logistic distribution.
|
||
|
lognormal Log-normal distribution.
|
||
|
logseries Logarithmic series distribution.
|
||
|
negative_binomial Negative binomial distribution.
|
||
|
noncentral_chisquare Non-central chi-square distribution.
|
||
|
noncentral_f Non-central F distribution.
|
||
|
normal Normal / Gaussian distribution.
|
||
|
pareto Pareto distribution.
|
||
|
poisson Poisson distribution.
|
||
|
power Power distribution.
|
||
|
rayleigh Rayleigh distribution.
|
||
|
triangular Triangular distribution.
|
||
|
uniform Uniform distribution.
|
||
|
vonmises Von Mises circular distribution.
|
||
|
wald Wald (inverse Gaussian) distribution.
|
||
|
weibull Weibull distribution.
|
||
|
zipf Zipf's distribution over ranked data.
|
||
|
==================== =========================================================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Multivariate distributions
|
||
|
==============================================================================
|
||
|
dirichlet Multivariate generalization of Beta distribution.
|
||
|
multinomial Multivariate generalization of the binomial distribution.
|
||
|
multivariate_normal Multivariate generalization of the normal distribution.
|
||
|
==================== =========================================================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Standard distributions
|
||
|
==============================================================================
|
||
|
standard_cauchy Standard Cauchy-Lorentz distribution.
|
||
|
standard_exponential Standard exponential distribution.
|
||
|
standard_gamma Standard Gamma distribution.
|
||
|
standard_normal Standard normal distribution.
|
||
|
standard_t Standard Student's t-distribution.
|
||
|
==================== =========================================================
|
||
|
|
||
|
==================== =========================================================
|
||
|
Internal functions
|
||
|
==============================================================================
|
||
|
get_state Get tuple representing internal state of generator.
|
||
|
set_state Set state of generator.
|
||
|
==================== =========================================================
|
||
|
|
||
|
"""
|
||
|
from __future__ import division, absolute_import, print_function
|
||
|
|
||
|
import warnings
|
||
|
|
||
|
# To get sub-modules
|
||
|
from .info import __doc__, __all__
|
||
|
|
||
|
|
||
|
with warnings.catch_warnings():
|
||
|
warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
|
||
|
from .mtrand import *
|
||
|
|
||
|
# Some aliases:
|
||
|
ranf = random = sample = random_sample
|
||
|
__all__.extend(['ranf', 'random', 'sample'])
|
||
|
|
||
|
def __RandomState_ctor():
|
||
|
"""Return a RandomState instance.
|
||
|
|
||
|
This function exists solely to assist (un)pickling.
|
||
|
|
||
|
Note that the state of the RandomState returned here is irrelevant, as this function's
|
||
|
entire purpose is to return a newly allocated RandomState whose state pickle can set.
|
||
|
Consequently the RandomState returned by this function is a freshly allocated copy
|
||
|
with a seed=0.
|
||
|
|
||
|
See https://github.com/numpy/numpy/issues/4763 for a detailed discussion
|
||
|
|
||
|
"""
|
||
|
return RandomState(seed=0)
|
||
|
|
||
|
from numpy.testing import _numpy_tester
|
||
|
test = _numpy_tester().test
|
||
|
bench = _numpy_tester().bench
|