MKL-powered RandomState

class mkl_random.MKLRandomState(seed=None, brng='MT19937')

Container for the Intel(R) MKL-powered (pseudo-)random number generators.

MKLRandomState exposes a number of methods for generating random numbers drawn from a variety of probability distributions. In addition to the distribution-specific arguments, each method takes a keyword argument size that defaults to None. If size is None, then a single value is generated and returned. If size is an integer, then a 1-D array filled with generated values is returned. If size is a tuple, then an array with that shape is filled and returned.

Compatibility Notice While this class shares some similarities with the original RandomState, it has been rewritten to use MKL’s vector statistics functionality, that provides efficient implementation of the MT19937 and many other basic psuedo-random number generation algorithms as well as efficient sampling from other common statistical distributions. As a consequence this version is NOT seed-compatible with the original RandomState.

Parameters:
seed{None, int, array_like}, optional

Random seed initializing the pseudo-random number generator. Can be an integer, an array (or other sequence) of integers of any length, or None (the default). If seed is None, then RandomState will try to read data from /dev/urandom (or the Windows analogue) if available or seed from the clock otherwise.

brngstr, optional

Name of the basic random number generation algorithm, or a non-deterministic hardware-based generator, provided by Intel MKL. One of ‘MT19937’, ‘SFMT19937’, ‘MT2203’, ‘R250’, ‘WH’, ‘MCG31’, ‘MCG59’, ‘MRG32K3A’, ‘PHILOX4X32X10’, ‘NONDETERM’, ‘ARS5’. The default is ‘MT19937’, the Mersenne Twister generator.

Notes

The Python stdlib module “random” also contains a Mersenne Twister pseudo-random number generator with a number of methods that are similar to the ones available in MKLRandomState. MKLRandomState, besides being NumPy-aware, has the advantage that it provides a much larger number of probability distributions to choose from.

References

MKL Documentation

Note

mkl_random.RandomState is a deprecated alias of mkl_random.MKLRandomState, kept for backward compatibility with legacy code. A NumPy-compatible drop-in replacement for numpy.random.RandomState is available in mkl_random.interfaces.numpy_random.

Seeding and state

seed

Seed the generator.

get_state

Return a tuple representing the internal state of the generator.

set_state

Set the internal state of the generator from a tuple.

Simple random data

rand

Random values in a given shape.

randn

Return a sample (or samples) from the "standard normal" distribution.

randint

Return random integers from low (inclusive) to high (exclusive).

random_integers

Random integers of type np.int between low and high, inclusive.

random_sample

Return random floats in the half-open interval [0.0, 1.0).

tomaxint

Return a sample of uniformly distributed random integers in the interval [0, np.iinfo("long").max].

choice

Generates a random sample from a given 1-D array

bytes

Return random bytes.

Permutations

shuffle

Modify a sequence in-place by shuffling its contents.

permutation

Randomly permute a sequence, or return a permuted range.

Distributions

beta

Draw samples from a Beta distribution.

binomial

Draw samples from a binomial distribution.

chisquare

Draw samples from a chi-square distribution.

dirichlet

Draw samples from the Dirichlet distribution.

exponential

Draw samples from an exponential distribution.

f

Draw samples from an F distribution.

gamma

Draw samples from a Gamma distribution.

geometric

Draw samples from the geometric distribution.

gumbel

Draw samples from a Gumbel distribution.

hypergeometric

Draw samples from a Hypergeometric distribution.

laplace

Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay).

logistic

Draw samples from a logistic distribution.

lognormal

Draw samples from a log-normal distribution.

logseries

Draw samples from a logarithmic series distribution.

multinomial

Draw samples from a multinomial distribution.

multivariate_normal

Draw random samples from a multivariate normal distribution.

negative_binomial

Draw samples from a negative binomial distribution.

noncentral_chisquare

Draw samples from a noncentral chi-square distribution.

noncentral_f

Draw samples from the noncentral F distribution.

normal

Draw random samples from a normal (Gaussian) distribution.

pareto

Draw samples from a Pareto II or Lomax distribution with specified shape.

poisson

Draw samples from a Poisson distribution.

power

Draws samples in [0, 1] from a power distribution with positive exponent a - 1.

rayleigh

Draw samples from a Rayleigh distribution.

standard_cauchy

Draw samples from a standard Cauchy distribution with mode = 0.

standard_exponential

Draw samples from the standard exponential distribution.

standard_gamma

Draw samples from a standard Gamma distribution.

standard_normal

Draw samples from a standard Normal distribution (mean=0, stdev=1).

standard_t

Draw samples from a standard Student's t distribution with df degrees of freedom.

triangular

Draw samples from the triangular distribution.

uniform

Draw samples from a uniform distribution.

vonmises

Draw samples from a von Mises distribution.

wald

Draw samples from a Wald, or inverse Gaussian, distribution.

weibull

Draw samples from a Weibull distribution.

zipf

Draw samples from a Zipf distribution.

MKL-specific methods

leapfrog

Initializes the current state generator using leap-frog method, if supported for the basic random pseudo-random number generation algorithm.

skipahead

Initializes the current state generator using skip-ahead method, if supported for the basic random pseudo-random number generation algorithm.

randint_untyped

Return random integers from low (inclusive) to high (exclusive).

multinormal_cholesky

Draw random samples from a multivariate normal distribution.