NumPy provides the random module. This module contains the functions which are used for generating random numbers. The most frequently used functions of this module are listed below:
Functions | Description |
rand() |
Returns random values drawn from uniform distribution in a given shape. |
randn() |
Returns random values drawn from standard normal distribution in a given shape. |
randint() |
Returns random integers drawn from specified range in a given shape. |
random_sample() |
Returns random floats in the half-open interval [0.0, 1.0) in a given shape. |
random() |
Returns random floats in the half-open interval [0.0, 1.0) in a given shape. |
ranf() |
Returns random floats in the half-open interval [0.0, 1.0) in a given shape. |
sample() |
Returns random floats in the half-open interval [0.0, 1.0) in a given shape. |
choice() |
Generates a random sample from a given 1-D array. |
bytes() |
Return random bytes. |
Functions | Description |
shuffle() |
Modify a sequence in-place by shuffling its contents. |
permutation() |
Randomly permute a sequence, or return a permuted range. |
Functions | Description |
binomial() |
Draw samples from a binomial distribution. |
exponential() |
Draw samples from a exponential distribution. |
geometric() |
Draw samples from a geometric distribution. |
logistic() |
Draw samples from a logistic distribution. |
normal() |
Draw samples from a normal distribution. |
poisson() |
Draw samples from a poisson distribution. |
uniform() |
Draw samples from a uniform distribution. |
Functions | Description |
seed() |
Seeds the generator. |