Package numpy :: Package random
[hide private]
[frames] | no frames]

Package random

source code

Core Random Tools



Functions [hide private]
 
__RandomState_ctor()
Return a RandomState instance.
source code
 
beta(...)
Beta distribution over [0, 1].
source code
 
binomial(...)
Binomial distribution of n trials and p probability of success.
source code
 
bytes(...)
Return random bytes.
source code
 
chisquare(...)
Chi^2 distribution.
source code
 
dirichlet(alpha, size=None)
Draw `size` samples of dimension k from a Dirichlet distribution.
source code
 
exponential(...)
Exponential distribution.
source code
 
f(...)
F distribution.
source code
 
gamma(...)
Gamma distribution.
source code
 
geometric(...)
Geometric distribution with p being the probability of "success" on an individual trial.
source code
 
get_state(...)
Return a tuple representing the internal state of the generator.
source code
 
gumbel(...)
Gumbel distribution.
source code
 
hypergeometric(...)
Hypergeometric distribution.
source code
 
laplace(...)
Laplace distribution.
source code
 
logistic(...)
Logistic distribution.
source code
 
lognormal(...)
Log-normal distribution.
source code
 
logseries(...)
Logarithmic series distribution.
source code
 
multinomial(...)
Multinomial distribution.
source code
 
multivariate_normal(...)
Return an array containing multivariate normally distributed random numbers with specified mean and covariance.
source code
 
negative_binomial(...)
Negative Binomial distribution.
source code
 
noncentral_chisquare(...)
Noncentral Chi^2 distribution.
source code
 
noncentral_f(...)
Noncentral F distribution.
source code
 
normal(...)
Normal distribution (mean=loc, stdev=scale).
source code
 
pareto(...)
Pareto distribution.
source code
 
permutation(...)
Given an integer, return a shuffled sequence of integers >= 0 and < x; given a sequence, return a shuffled array copy.
source code
 
poisson(...)
Poisson distribution.
source code
 
power(...)
Power distribution.
source code
 
rand(...)
Return an array of the given dimensions which is initialized to random numbers from a uniform distribution in the range [0,1).
source code
 
randint(...)
Return random integers x such that low <= x < high.
source code
 
randn(...)
Returns zero-mean, unit-variance Gaussian random numbers in an array of shape (d0, d1, ..., dn).
source code
 
random(...)
Return random floats in the half-open interval [0.0, 1.0).
source code
 
random_integers(...)
Return random integers x such that low <= x <= high.
source code
 
random_sample(...)
Return random floats in the half-open interval [0.0, 1.0).
source code
 
ranf(...)
Return random floats in the half-open interval [0.0, 1.0).
source code
 
rayleigh(...)
Rayleigh distribution.
source code
 
sample(...)
Return random floats in the half-open interval [0.0, 1.0).
source code
 
seed(...)
Seed the generator.
source code
 
set_state(...)
Set the state from a tuple.
source code
 
shuffle(...)
Modify a sequence in-place by shuffling its contents.
source code
 
standard_cauchy(...)
Standard Cauchy with mode=0.
source code
 
standard_exponential(...)
Standard exponential distribution (scale=1).
source code
 
standard_gamma(...)
Standard Gamma distribution.
source code
 
standard_normal(...)
Standard Normal distribution (mean=0, stdev=1).
source code
 
standard_t(...)
Standard Student's t distribution with df degrees of freedom.
source code
 
test(level=1, verbosity=1) source code
 
triangular(...)
Triangular distribution starting at left, peaking at mode, and ending at right (left <= mode <= right).
source code
 
uniform(...)
Uniform distribution over [low, high).
source code
 
vonmises(...)
von Mises circular distribution with mode mu and dispersion parameter kappa on [-pi, pi].
source code
 
wald(...)
Wald (inverse Gaussian) distribution.
source code
 
weibull(...)
Weibull distribution.
source code
 
zipf(...)
Zipf distribution.
source code
Function Details [hide private]

__RandomState_ctor()

source code 

Return a RandomState instance.

This function exists solely to assist (un)pickling.

beta(...)

source code 

Beta distribution over [0, 1].

beta(a, b, size=None) -> random values

binomial(...)

source code 

Binomial distribution of n trials and p probability of success.

binomial(n, p, size=None) -> random values

bytes(...)

source code 

Return random bytes.

bytes(length) -> str

chisquare(...)

source code 

Chi^2 distribution.

chisquare(df, size=None) -> random values

dirichlet(alpha, size=None)

source code 
Draw `size` samples of dimension k from a Dirichlet distribution. A 
Dirichlet-distributed random variable can be seen as a multivariate 
generalization of a Beta distribution. Dirichlet pdf is the conjugate
prior of a multinomial in Bayesian inference.

:Parameters:
    alpha : array
        parameter of the distribution (k dimension
              for sample of dimension k).
    size : array
        number of samples to draw.

$X pprox \prod_{i=1}^{k}{x^{lpha_i-1}_i}$

Uses the following property for computation: for each dimension,
draw a random sample y_i from a standard gamma generator of shape 
alpha_i, then X = rac{1}{\sum_{i=1}^k{y_i}} (y_1, ..., y_n) is 
Dirichlet distributed. 

Reference:
    - David Mc Kay : Information Theory, inference and Learning 
         algorithms, chapter 23. the book is available for free at 
         http://www.inference.phy.cam.ac.uk/mackay/

exponential(...)

source code 

Exponential distribution.

exponential(scale=1.0, size=None) -> random values

f(...)

source code 

F distribution.

f(dfnum, dfden, size=None) -> random values

gamma(...)

source code 

Gamma distribution.

gamma(shape, scale=1.0, size=None) -> random values

geometric(...)

source code 

Geometric distribution with p being the probability of "success" on an individual trial.

geometric(p, size=None)

get_state(...)

source code 

Return a tuple representing the internal state of the generator.

get_state() -> ('MT19937', int key[624], int pos)

gumbel(...)

source code 

Gumbel distribution.

gumbel(loc=0.0, scale=1.0, size=None)

hypergeometric(...)

source code 

Hypergeometric distribution.

Consider an urn with ngood "good" balls and nbad "bad" balls. If one were to draw nsample balls from the urn without replacement, then the hypergeometric distribution describes the distribution of "good" balls in the sample.

hypergeometric(ngood, nbad, nsample, size=None)

laplace(...)

source code 

Laplace distribution.

laplace(loc=0.0, scale=1.0, size=None)

logistic(...)

source code 

Logistic distribution.

logistic(loc=0.0, scale=1.0, size=None)

lognormal(...)

source code 
Log-normal distribution.

Note that the mean parameter is not the mean of this distribution, but 
the underlying normal distribution.

    lognormal(mean, sigma) <=> exp(normal(mean, sigma))

lognormal(mean=0.0, sigma=1.0, size=None)

logseries(...)

source code 

Logarithmic series distribution.

logseries(p, size=None)

multinomial(...)

source code 

Multinomial distribution.

multinomial(n, pvals, size=None) -> random values

pvals is a sequence of probabilities that should sum to 1 (however, the last element is always assumed to account for the remaining probability as long as sum(pvals[:-1]) <= 1).

multivariate_normal(...)

source code 

Return an array containing multivariate normally distributed random numbers with specified mean and covariance.

multivariate_normal(mean, cov) -> random values multivariate_normal(mean, cov, [m, n, ...]) -> random values

mean must be a 1 dimensional array. cov must be a square two dimensional array with the same number of rows and columns as mean has elements.

The first form returns a single 1-D array containing a multivariate normal.

The second form returns an array of shape (m, n, ..., cov.shape[0]). In this case, output[i,j,...,:] is a 1-D array containing a multivariate normal.

negative_binomial(...)

source code 

Negative Binomial distribution.

negative_binomial(n, p, size=None) -> random values

noncentral_chisquare(...)

source code 

Noncentral Chi^2 distribution.

noncentral_chisquare(df, nonc, size=None) -> random values

noncentral_f(...)

source code 

Noncentral F distribution.

noncentral_f(dfnum, dfden, nonc, size=None) -> random values

normal(...)

source code 

Normal distribution (mean=loc, stdev=scale).

normal(loc=0.0, scale=1.0, size=None) -> random values

pareto(...)

source code 

Pareto distribution.

pareto(a, size=None)

permutation(...)

source code 

Given an integer, return a shuffled sequence of integers >= 0 and < x; given a sequence, return a shuffled array copy.

permutation(x)

poisson(...)

source code 

Poisson distribution.

poisson(lam=1.0, size=None) -> random values

power(...)

source code 

Power distribution.

power(a, size=None)

rand(...)

source code 
Return an array of the given dimensions which is initialized to 
random numbers from a uniform distribution in the range [0,1).

rand(d0, d1, ..., dn) -> random values

Note:  This is a convenience function. If you want an
            interface that takes a tuple as the first argument
            use numpy.random.random_sample(shape_tuple).

randint(...)

source code 

Return random integers x such that low <= x < high.

randint(low, high=None, size=None) -> random values

If high is None, then 0 <= x < low.

randn(...)

source code 
Returns zero-mean, unit-variance Gaussian random numbers in an 
array of shape (d0, d1, ..., dn).

randn(d0, d1, ..., dn) -> random values

Note:  This is a convenience function. If you want an
            interface that takes a tuple as the first argument
            use numpy.random.standard_normal(shape_tuple).

random(...)

source code 

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

random_sample(size=None) -> random values

random_integers(...)

source code 

Return random integers x such that low <= x <= high.

random_integers(low, high=None, size=None) -> random values.

If high is None, then 1 <= x <= low.

random_sample(...)

source code 

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

random_sample(size=None) -> random values

ranf(...)

source code 

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

random_sample(size=None) -> random values

rayleigh(...)

source code 

Rayleigh distribution.

rayleigh(scale=1.0, size=None)

sample(...)

source code 

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

random_sample(size=None) -> random values

seed(...)

source code 

Seed the generator.

seed(seed=None)

seed can be an integer, an array (or other sequence) of integers of any length, or None. 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.

set_state(...)

source code 

Set the state from a tuple.

state = ('MT19937', int key[624], int pos)

set_state(state)

shuffle(...)

source code 

Modify a sequence in-place by shuffling its contents.

shuffle(x)

standard_cauchy(...)

source code 

Standard Cauchy with mode=0.

standard_cauchy(size=None)

standard_exponential(...)

source code 

Standard exponential distribution (scale=1).

standard_exponential(size=None) -> random values

standard_gamma(...)

source code 

Standard Gamma distribution.

standard_gamma(shape, size=None) -> random values

standard_normal(...)

source code 

Standard Normal distribution (mean=0, stdev=1).

standard_normal(size=None) -> random values

standard_t(...)

source code 

Standard Student's t distribution with df degrees of freedom.

standard_t(df, size=None)

triangular(...)

source code 

Triangular distribution starting at left, peaking at mode, and ending at right (left <= mode <= right).

triangular(left, mode, right, size=None)

uniform(...)

source code 

Uniform distribution over [low, high).

uniform(low=0.0, high=1.0, size=None) -> random values

vonmises(...)

source code 

von Mises circular distribution with mode mu and dispersion parameter kappa on [-pi, pi].

vonmises(mu, kappa, size=None)

wald(...)

source code 

Wald (inverse Gaussian) distribution.

wald(mean, scale, size=None)

weibull(...)

source code 

Weibull distribution.

weibull(a, size=None)

zipf(...)

source code 

Zipf distribution.

zipf(a, size=None)